Class: TZInfo::TZDataLocation
- Inherits:
-
Object
- Object
- TZInfo::TZDataLocation
- Defined in:
- lib/tzinfo/tzdataparser.rb
Overview
A location (latitude + longitude)
Instance Attribute Summary collapse
-
#latitude ⇒ Object
readonly
:nodoc:.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
Instance Method Summary collapse
-
#initialize(coordinates) ⇒ TZDataLocation
constructor
Constructs a new TZDataLocation from a string in ISO 6709 sign-degrees-minutes-seconds format, either
-DDMM
-DDDMM or-DDMMSS
-DDDMMSS, first latitude (+ is north), then longitude (+ is east).
Constructor Details
#initialize(coordinates) ⇒ TZDataLocation
Constructs a new TZDataLocation from a string in ISO 6709 sign-degrees-minutes-seconds format, either -DDMM
-DDDMM or -DDMMSS
-DDDMMSS, first latitude (+ is north), then longitude (+ is east).
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 |
# File 'lib/tzinfo/tzdataparser.rb', line 1128 def initialize(coordinates) if coordinates !~ /^([+\-])([0-9]{2})([0-9]{2})([0-9]{2})?([+\-])([0-9]{3})([0-9]{2})([0-9]{2})?$/ raise "Invalid coordinates: #{coordinates}" end @latitude = Rational($2.to_i) + Rational($3.to_i, 60) @latitude += Rational($4.to_i, 3600) unless $4.nil? @latitude = -@latitude if $1 == '-' @longitude = Rational($6.to_i) + Rational($7.to_i, 60) @longitude += Rational($8.to_i, 3600) unless $8.nil? @longitude = -@longitude if $5 == '-' end |
Instance Attribute Details
#latitude ⇒ Object (readonly)
:nodoc:
1121 1122 1123 |
# File 'lib/tzinfo/tzdataparser.rb', line 1121 def latitude @latitude end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
1122 1123 1124 |
# File 'lib/tzinfo/tzdataparser.rb', line 1122 def longitude @longitude end |