Sha256: f375737a8a868a2ab2e592c7bd3aac7c35c32c028f3e594d1b3aca93344a0d40

Contents?: true

Size: 613 Bytes

Versions: 2

Compression:

Stored size: 613 Bytes

Contents

class String
  def to_rad
    parse_dms.to_rad
  end

  def trim
    strip
  end

  def geo_clean
    self.gsub(/^\(/, '').gsub(/\)$/, '').trim
  end
    
  def to_lat_lng  
    geo_clean.split(',').to_lat_lng
  end

  def to_lng_lat  
    geo_clean.split(',').to_lng_lat
  end
  
  def to_lat
    raise "An empty String has no latitude" if self.empty?
    s = geo_clean
    s = s.parse_dms if s.respond_to? :parse_dms
    s.to_f.to_lat
  end

  def to_lng
    raise "An empty String has no latitude" if self.empty?
    s = geo_clean
    s = s.parse_dms if s.respond_to? :parse_dms    
    s.to_f.to_lng
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geo_calc-0.7.4 lib/geo_calc/extensions/string.rb
geo_calc-0.7.3 lib/geo_calc/extensions/string.rb