Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/ext/string.rb

Instance Method Summary collapse

Instance Method Details

#city_info(**kwargs) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ext/string.rb', line 18

def city_info(**kwargs)
  # Cleanup "self"
  key = self.delete(' ').upcase

  info = Zipcoder.city_lookup[key]

  # Filter to the included keys
  if kwargs[:keys] != nil
    new_info = {}
    kwargs[:keys].each { |k| new_info[k] = info[k] }
    info = new_info
  end

  info
end

#zip_info(**kwargs) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ext/string.rb', line 5

def zip_info(**kwargs)
  info = Zipcoder.zip_lookup[self]

  # Filter to the included keys
  if kwargs[:keys] != nil
    new_info = {}
    kwargs[:keys].each { |k| new_info[k] = info[k] }
    info = new_info
  end

  info
end