Module: GeoTools::Location::InstanceMethodsOnActivation
- Defined in:
- lib/geo_tools/location.rb
Instance Method Summary collapse
- #latitude ⇒ Object
- #latitude_decimal_minutes=(value) ⇒ Object
- #latitude_decimal_minutes_as_string ⇒ Object
- #longitude ⇒ Object
- #longitude_decimal_minutes=(value) ⇒ Object
- #longitude_decimal_minutes_as_string ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#latitude ⇒ Object
195 196 197 198 |
# File 'lib/geo_tools/location.rb', line 195 def latitude to_float latitude_degrees, latitude_minutes, latitude_decimal_minutes, latitude_decimal_minutes_width, latitude_hemisphere end |
#latitude_decimal_minutes=(value) ⇒ Object
167 168 169 170 171 172 173 174 175 |
# File 'lib/geo_tools/location.rb', line 167 def latitude_decimal_minutes=(value) unless value.nil? width = value.to_s.length value = value.to_i write_attribute :latitude_decimal_minutes, value write_attribute :latitude_decimal_minutes_width, width end end |
#latitude_decimal_minutes_as_string ⇒ Object
177 178 179 |
# File 'lib/geo_tools/location.rb', line 177 def latitude_decimal_minutes_as_string "%0#{latitude_decimal_minutes_width}d" % (latitude_decimal_minutes || 0) end |
#longitude ⇒ Object
200 201 202 203 |
# File 'lib/geo_tools/location.rb', line 200 def longitude to_float longitude_degrees, longitude_minutes, longitude_decimal_minutes, longitude_decimal_minutes_width, longitude_hemisphere end |
#longitude_decimal_minutes=(value) ⇒ Object
181 182 183 184 185 186 187 188 189 |
# File 'lib/geo_tools/location.rb', line 181 def longitude_decimal_minutes=(value) unless value.nil? width = value.to_s.length value = value.to_i write_attribute :longitude_decimal_minutes, value write_attribute :longitude_decimal_minutes_width, width end end |
#longitude_decimal_minutes_as_string ⇒ Object
191 192 193 |
# File 'lib/geo_tools/location.rb', line 191 def longitude_decimal_minutes_as_string "%0#{longitude_decimal_minutes_width}d" % (longitude_decimal_minutes || 0) end |
#to_s ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/geo_tools/location.rb', line 205 def to_s # Unicode degree symbol, full stop, Unicode minute symbol. units = [ "\xc2\xb0", '.', "\xe2\x80\xb2" ] lat_fields = ["%02d" % (latitude_degrees || 0), "%02d" % (latitude_minutes || 0), latitude_decimal_minutes_as_string.ljust(2, '0'), latitude_hemisphere] lat = lat_fields.zip(units).map{ |f| f.join }.join long_fields = ["%02d" % (longitude_degrees || 0), "%02d" % (longitude_minutes || 0), longitude_decimal_minutes_as_string.ljust(2, '0'), longitude_hemisphere] long = long_fields.zip(units).map{ |f| f.join }.join "#{lat}, #{long}" end |