Class: Locus::Place
- Inherits:
-
Object
- Object
- Locus::Place
- Defined in:
- lib/locus/place.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
Returns the value of attribute country.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#state_code ⇒ Object
Returns the value of attribute state_code.
Class Method Summary collapse
-
.find_by_postal_code(postal_code, country = Locus.default_country) ⇒ Place
Find a place by postal code and country.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Place
constructor
A new instance of Place.
Constructor Details
#initialize(attributes = {}) ⇒ Place
Returns a new instance of Place.
7 8 9 10 11 |
# File 'lib/locus/place.rb', line 7 def initialize(attributes = {}) attributes.each do |key, value| send("#{key}=", value) end end |
Instance Attribute Details
#country ⇒ Object
Returns the value of attribute country.
5 6 7 |
# File 'lib/locus/place.rb', line 5 def country @country end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
5 6 7 |
# File 'lib/locus/place.rb', line 5 def postal_code @postal_code end |
#state_code ⇒ Object
Returns the value of attribute state_code.
5 6 7 |
# File 'lib/locus/place.rb', line 5 def state_code @state_code end |
Class Method Details
.find_by_postal_code(postal_code, country = Locus.default_country) ⇒ Place
Find a place by postal code and country.
22 23 24 25 26 27 |
# File 'lib/locus/place.rb', line 22 def self.find_by_postal_code(postal_code, country = Locus.default_country) return nil unless state_code = state_code(postal_code, country) self.new(country: country, postal_code: postal_code, state_code: state_code) end |