Class: Integer
- Inherits:
-
Object
- Object
- Integer
- Defined in:
- lib/area/integer.rb
Instance Method Summary collapse
-
#to_gmt_offset ⇒ Object
Public: Convert a zipcode to its GMT offset.
-
#to_lat ⇒ Object
Public: Convert a zipcode to its latitude.
-
#to_latlon ⇒ Object
Public: Convert an area code or zipcode to its latitude and longitude.
-
#to_lon ⇒ Object
Public: Convert a zipcode to its longitude.
-
#to_region(options = {}) ⇒ Object
Public: Convert an area code or to a US state or region.
Instance Method Details
#to_gmt_offset ⇒ Object
Public: Convert a zipcode to its GMT offset.
Examples
11211.to_gmt_offset
#=> "-5"
Returns a String representation of the GMT offset.
79 80 81 82 83 84 85 |
# File 'lib/area/integer.rb', line 79 def to_gmt_offset if Area.zip?(self) warn "[DEPRECATION] using `to_gmt` with an integer representaion of a zipcode is deprecated and will be removed in future versions. Please use a string instead." row = Area.zip_codes.find {|row| row.first == self.to_s } row[5] if row end end |
#to_lat ⇒ Object
Public: Convert a zipcode to its latitude.
Examples
11211.to_lat
#=> "40.71209"
Returns a String representation of the latitude.
45 46 47 48 49 50 51 |
# File 'lib/area/integer.rb', line 45 def to_lat if Area.zip?(self) warn "[DEPRECATION] using `to_lat` with an integer representation of a zipcode is deprecated and will be removed in future versions. Please use a string instead." row = Area.zip_codes.find {|row| row.first == self.to_s } row[3] if row end end |
#to_latlon ⇒ Object
Public: Convert an area code or zipcode to its latitude and longitude.
Examples
11211.to_latlon
#=> "40.71209, -73.95427"
Returns a String representation of the lat/lon pair.
28 29 30 31 32 33 34 |
# File 'lib/area/integer.rb', line 28 def to_latlon if Area.zip?(self) warn "[DEPRECATION] using `to_latlon` with an integer representation of a zipcode is deprecated and will be removed in future versions. Please use a string instead." row = Area.zip_codes.find {|row| row.first == self.to_s } row[3] + ', ' + row[4] if row end end |
#to_lon ⇒ Object
Public: Convert a zipcode to its longitude.
Examples
11211.to_lon
#=> "40.71209"
Returns a String representation of the longitude.
62 63 64 65 66 67 68 |
# File 'lib/area/integer.rb', line 62 def to_lon if Area.zip?(self) warn "[DEPRECATION] using `to_lon` with an integer representaion of a zipcode is deprecated and will be removed in future versions. Please use a string instead." row = Area.zip_codes.find {|row| row.first == self.to_s } row[4] if row end end |
#to_region(options = {}) ⇒ Object
Public: Convert an area code or to a US state or region.
Examples
646.to_region
#=> NY
Returns a String representation of the converted area code.
12 13 14 15 16 17 |
# File 'lib/area/integer.rb', line 12 def to_region( = {}) if Area.code?(self) # presume an area code row = Area.area_codes.find{|row| row.first == self.to_s } row.last if row end end |