Class: Rlocu::Menu
- Inherits:
-
Object
- Object
- Rlocu::Menu
- Defined in:
- lib/rlocu/menu.rb
Defined Under Namespace
Classes: Item, MenuItem, Option, OptionGroup, Section, SectionText, Subsection
Instance Attribute Summary collapse
-
#menu_name ⇒ Object
readonly
Returns the value of attribute menu_name.
-
#sections ⇒ Object
Returns the value of attribute sections.
Instance Method Summary collapse
-
#initialize(menu_hash) ⇒ Menu
constructor
A new instance of Menu.
- #to_s ⇒ Object
Constructor Details
#initialize(menu_hash) ⇒ Menu
Returns a new instance of Menu.
5 6 7 8 |
# File 'lib/rlocu/menu.rb', line 5 def initialize() @menu_name = ['menu_name'] self.sections = ['sections'] end |
Instance Attribute Details
#menu_name ⇒ Object (readonly)
Returns the value of attribute menu_name.
3 4 5 |
# File 'lib/rlocu/menu.rb', line 3 def @menu_name end |
#sections ⇒ Object
Returns the value of attribute sections.
3 4 5 |
# File 'lib/rlocu/menu.rb', line 3 def sections @sections end |
Instance Method Details
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rlocu/menu.rb', line 15 def to_s str = "Menu: #{}\n" sections.each do |section| str << "-----#{section.section_name}-----\n" section.subsections.each do |subsection| str << "---#{subsection.subsection_name}---\n" subsection.contents.each do |content| case content when SectionText str << "SECTION TEXT : #{content.to_s}\n" when MenuItem str << "MENU ITEM : #{content.name} #{content.description} #{content.price}\n" content.option_groups.each do |opt_group| str << "OPTION GROUP : #{opt_group.text}\n" opt_group..each do |option| str << "OPTION : #{option.to_s}\n" end end end end end end str end |