Class: SinglePlatform::Menu

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location, data) ⇒ Menu

Returns a new instance of Menu.



7
8
9
10
11
12
13
14
# File 'lib/single_platform/menu.rb', line 7

def initialize(location, data)
  @location = location
  @menu_sections = []
  data.each do |key, value|
    instance_variable_set :"@#{key.underscore}", value
  end
  build_menu
end

Instance Attribute Details

#attribution_imageObject (readonly)

Returns the value of attribute attribution_image.



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

def attribution_image
  @attribution_image
end

Returns the value of attribute attribution_image_link.



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

def attribution_image_link
  @attribution_image_link
end

#descObject (readonly)

Returns the value of attribute desc.



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

def desc
  @desc
end

#disclaimerObject (readonly)

Returns the value of attribute disclaimer.



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

def disclaimer
  @disclaimer
end

#entriesObject (readonly)

Returns the value of attribute entries.



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

def entries
  @entries
end

#footnoteObject (readonly)

Returns the value of attribute footnote.



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

def footnote
  @footnote
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

Returns the value of attribute menu_sections.



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

def menu_sections
  @menu_sections
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#secure_attribution_imageObject (readonly)

Returns the value of attribute secure_attribution_image.



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

def secure_attribution_image
  @secure_attribution_image
end

Returns the value of attribute secure_attribution_image_link.



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

def secure_attribution_image_link
  @secure_attribution_image_link
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Class Method Details



16
17
18
19
# File 'lib/single_platform/menu.rb', line 16

def self.menus_for_location(location)
  data = SinglePlatform::Request.get("/locations/#{location.id}/menu").body["menus"]
  data.collect { |menu_data| new(location, menu_data) }
end

Instance Method Details

#build_menuObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/single_platform/menu.rb', line 21

def build_menu
  current_section = nil
  entries.each do |entry|
    if entry["type"] == "section"
      current_section = SinglePlatform::MenuSection.new(self, entry)
      menu_sections << current_section
    else
      current_section.menu_items << SinglePlatform::MenuItem.new(current_section, entry)
    end
  end
end