Class: Position
- Inherits:
-
Object
- Object
- Position
- Defined in:
- lib/pr2gpx/parser.rb
Instance Attribute Summary collapse
-
#latitude ⇒ Object
readonly
Returns the value of attribute latitude.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(latitude, longitude) ⇒ Position
constructor
A new instance of Position.
- #parse_angle(value) ⇒ Object
Constructor Details
#initialize(latitude, longitude) ⇒ Position
Returns a new instance of Position.
10 11 12 13 |
# File 'lib/pr2gpx/parser.rb', line 10 def initialize latitude, longitude @latitude = parse_angle latitude @longitude = parse_angle longitude end |
Instance Attribute Details
#latitude ⇒ Object (readonly)
Returns the value of attribute latitude.
8 9 10 |
# File 'lib/pr2gpx/parser.rb', line 8 def latitude @latitude end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
8 9 10 |
# File 'lib/pr2gpx/parser.rb', line 8 def longitude @longitude end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 18 |
# File 'lib/pr2gpx/parser.rb', line 15 def == other self.latitude == other.latitude and self.longitude == other.longitude end |
#parse_angle(value) ⇒ Object
20 21 22 23 24 |
# File 'lib/pr2gpx/parser.rb', line 20 def parse_angle value if /(?<degrees>\d+)-(?<minutes>\d+\.\d+)(?<sign>[NSWE])/ =~ value (degrees.to_f + minutes.to_f / 60) * ((sign == 'S' or sign == 'W') ? -1 : 1) end end |