Class: SinglePlatform::Location

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Location

Returns a new instance of Location.



13
14
15
16
17
# File 'lib/single_platform/location.rb', line 13

def initialize(data)
  data.each do |key, value|
    instance_variable_set :"@#{key.underscore}", value
  end
end

Instance Attribute Details

#business_typeObject (readonly)

Returns the value of attribute business_type.



3
4
5
# File 'lib/single_platform/location.rb', line 3

def business_type
  @business_type
end

#factual_idObject (readonly)

Returns the value of attribute factual_id.



3
4
5
# File 'lib/single_platform/location.rb', line 3

def factual_id
  @factual_id
end

#generalObject (readonly)

Returns the value of attribute general.



3
4
5
# File 'lib/single_platform/location.rb', line 3

def general
  @general
end

#hoursObject (readonly)

Returns the value of attribute hours.



3
4
5
# File 'lib/single_platform/location.rb', line 3

def hours
  @hours
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/single_platform/location.rb', line 3

def id
  @id
end

#locationObject (readonly)

Returns the value of attribute location.



3
4
5
# File 'lib/single_platform/location.rb', line 3

def location
  @location
end

Returns the value of attribute menus.



4
5
6
# File 'lib/single_platform/location.rb', line 4

def menus
  @menus
end

#out_of_businessObject (readonly)

Returns the value of attribute out_of_business.



3
4
5
# File 'lib/single_platform/location.rb', line 3

def out_of_business
  @out_of_business
end

#phonesObject (readonly)

Returns the value of attribute phones.



3
4
5
# File 'lib/single_platform/location.rb', line 3

def phones
  @phones
end

#published_atObject (readonly)

Returns the value of attribute published_at.



3
4
5
# File 'lib/single_platform/location.rb', line 3

def published_at
  @published_at
end

Class Method Details

.in_zipcode(zipcode, opts = {}) ⇒ Object



6
7
8
9
10
11
# File 'lib/single_platform/location.rb', line 6

def self.in_zipcode(zipcode, opts={})
  data = in_zipcode_request(zipcode, opts)
  locations = parse_locations(data)
  locations.each(&:fetch_menus) if opts[:include_menus]
  locations
end

Instance Method Details

#fetch_menusObject



19
20
21
# File 'lib/single_platform/location.rb', line 19

def fetch_menus
  @menus = SinglePlatform::Menu.menus_for_location(self)
end