Class: Barometer::Query::Format::Coordinates

Inherits:
Base
  • Object
show all
Defined in:
lib/barometer/query/formats/coordinates.rb

Overview

eg. 123.1234,-123.123

Class Method Summary collapse

Methods inherited from Base

convert_query, is?

Class Method Details

.geo(query) ⇒ Object



10
11
12
13
14
15
# File 'lib/barometer/query/formats/coordinates.rb', line 10

def self.geo(query)
  return unless query

  coordinates = query.split(',')
  {latitude: coordinates[0].to_f, longitude: coordinates[1].to_f}
end

.regexObject



8
# File 'lib/barometer/query/formats/coordinates.rb', line 8

def self.regex; /^[-]?[0-9\.]+[,]{1}\s?[-]?[0-9\.]+$/; end