Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/geoinfo/string.rb
Instance Method Summary collapse
Instance Method Details
#to_region(options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/geoinfo/string.rb', line 3 def to_region( = {}) Geoinfo::ZIP_CODES.each do |row| if row.second == self.to_s if [:district] @region = row[5] elsif [:state] @region = row[3] elsif [:country] @region = row[0] elsif [:lat] @region = row[9] elsif [:log] @region = row[10] elsif [:state_code] @region = row[4] else @region = row[2] end end end @region || nil end |
#to_zip ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/geoinfo/string.rb', line 26 def to_zip @zip_codes = [] Geoinfo::ZIP_CODES.each do |row| @zip_codes.push(row[1]) if row[2].chomp == self.chomp end @zip_codes.length == 1 ? @zip_codes.first : @zip_codes end |