Class: ZipCodeInfo
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
-
#initialize ⇒ ZipCodeInfo
constructor
A new instance of ZipCodeInfo.
- #scf_city_for(code = '') ⇒ Object
- #state_for(code = '') ⇒ Object
Constructor Details
#initialize ⇒ ZipCodeInfo
Returns a new instance of ZipCodeInfo.
9 10 11 |
# File 'lib/zip-code-info.rb', line 9 def initialize @data = YAML.load(File.open(File.join(File.dirname(__FILE__), '..', 'data', 'data.yml'))) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
7 8 9 |
# File 'lib/zip-code-info.rb', line 7 def code @code end |
Instance Method Details
#scf_city_for(code = '') ⇒ Object
13 14 15 16 |
# File 'lib/zip-code-info.rb', line 13 def scf_city_for(code = '') return false unless assign_and_validate_code(code) @data[code_to_key][:city] end |
#state_for(code = '') ⇒ Object
18 19 20 21 |
# File 'lib/zip-code-info.rb', line 18 def state_for(code = '') return false unless assign_and_validate_code(code) @data[code_to_key][:state] end |