Class: PartialMenu::Menu

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

Overview

Represents a menu with menu items

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props, type = 'main', parent = nil) ⇒ Menu

Returns a new instance of Menu.



11
12
13
14
15
16
17
18
19
# File 'lib/partial_menu/menu.rb', line 11

def initialize(props, type = 'main', parent = nil)
  raise "Expected a array but got #{props.class}" unless props.is_a? Array
  raise "Expected a string but got #{type.class}" unless type.is_a? String
  @type = type
  @items = []
  @parent = parent
  set_id
  add_items(props)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/partial_menu/menu.rb', line 9

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



7
8
9
# File 'lib/partial_menu/menu.rb', line 7

def items
  @items
end

#parentObject (readonly)

Returns the value of attribute parent.



8
9
10
# File 'lib/partial_menu/menu.rb', line 8

def parent
  @parent
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/partial_menu/menu.rb', line 6

def type
  @type
end