Class: Store

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#addressObject

Returns the value of attribute address.



2
3
4
# File 'lib/store.rb', line 2

def address
  @address
end

#area_codeObject

Returns the value of attribute area_code.



2
3
4
# File 'lib/store.rb', line 2

def area_code
  @area_code
end

#cityObject

Returns the value of attribute city.



2
3
4
# File 'lib/store.rb', line 2

def city
  @city
end

#geohashObject

Returns the value of attribute geohash.



2
3
4
# File 'lib/store.rb', line 2

def geohash
  @geohash
end

#latObject

Returns the value of attribute lat.



2
3
4
# File 'lib/store.rb', line 2

def lat
  @lat
end

#longObject

Returns the value of attribute long.



2
3
4
# File 'lib/store.rb', line 2

def long
  @long
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/store.rb', line 2

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



2
3
4
# File 'lib/store.rb', line 2

def phone
  @phone
end

#stateObject

Returns the value of attribute state.



2
3
4
# File 'lib/store.rb', line 2

def state
  @state
end

#uuidObject

Returns the value of attribute uuid.



2
3
4
# File 'lib/store.rb', line 2

def uuid
  @uuid
end

#zipObject

Returns the value of attribute zip.



2
3
4
# File 'lib/store.rb', line 2

def zip
  @zip
end

Instance Method Details

#to_hObject



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