Class: Ubr::Coordinate

Inherits:
Struct
  • Object
show all
Defined in:
lib/ubr/coordinate.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#latitudeObject

Returns the value of attribute latitude

Returns:

  • (Object)

    the current value of latitude



4
5
6
# File 'lib/ubr/coordinate.rb', line 4

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude

Returns:

  • (Object)

    the current value of longitude



4
5
6
# File 'lib/ubr/coordinate.rb', line 4

def longitude
  @longitude
end

Class Method Details

.parse(text) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/ubr/coordinate.rb', line 7

def parse(text)
  if text =~ /\A(\-?[\d\.]+),(\-?[\d\.]+)\Z/
    Coordinate.new($1.to_f, $2.to_f)
  else
    raise "Coordinate must be in format 'latitude,longitude'; #{text.inspect} given"
  end
end