Class: Store
- Inherits:
-
Object
- Object
- Store
- Defined in:
- lib/store.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#area_code ⇒ Object
Returns the value of attribute area_code.
-
#city ⇒ Object
Returns the value of attribute city.
-
#geohash ⇒ Object
Returns the value of attribute geohash.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#long ⇒ Object
Returns the value of attribute long.
-
#name ⇒ Object
Returns the value of attribute name.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#state ⇒ Object
Returns the value of attribute state.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
-
#zip ⇒ Object
Returns the value of attribute zip.
Instance Method Summary collapse
-
#initialize(store_data) ⇒ Store
constructor
A new instance of Store.
- #to_h ⇒ Object
Constructor Details
#initialize(store_data) ⇒ Store
Returns a new instance of Store.
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/store.rb', line 3 def initialize(store_data) @lat = store_data[:latitude] @long = store_data[:longitude] @address = store_data[:address] @city = store_data[:city] @state = store_data[:state] @zip = store_data[:zip] @area_code = store_data[:area_code] @phone = store_data[:phone] @name = store_data[:name] @geohash = store_data[:geohash] || Geohash.encode(lat, long, 10) @uuid = store_data[:uuid] end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
2 3 4 |
# File 'lib/store.rb', line 2 def address @address end |
#area_code ⇒ Object
Returns the value of attribute area_code.
2 3 4 |
# File 'lib/store.rb', line 2 def area_code @area_code end |
#city ⇒ Object
Returns the value of attribute city.
2 3 4 |
# File 'lib/store.rb', line 2 def city @city end |
#geohash ⇒ Object
Returns the value of attribute geohash.
2 3 4 |
# File 'lib/store.rb', line 2 def geohash @geohash end |
#lat ⇒ Object
Returns the value of attribute lat.
2 3 4 |
# File 'lib/store.rb', line 2 def lat @lat end |
#long ⇒ Object
Returns the value of attribute long.
2 3 4 |
# File 'lib/store.rb', line 2 def long @long end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/store.rb', line 2 def name @name end |
#phone ⇒ Object
Returns the value of attribute phone.
2 3 4 |
# File 'lib/store.rb', line 2 def phone @phone end |
#state ⇒ Object
Returns the value of attribute state.
2 3 4 |
# File 'lib/store.rb', line 2 def state @state end |
#uuid ⇒ Object
Returns the value of attribute uuid.
2 3 4 |
# File 'lib/store.rb', line 2 def uuid @uuid end |
#zip ⇒ Object
Returns the value of attribute zip.
2 3 4 |
# File 'lib/store.rb', line 2 def zip @zip end |
Instance Method Details
#to_h ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/store.rb', line 17 def to_h temp = instance_variables.map do |v| value = self.send(v.to_s.sub('@','')) value = value.class == BigDecimal ? value.to_f : value Hash[v.to_s.sub('@','').to_sym, value] end Hash[*temp.collect{|h| h.to_a}.flatten] end |