Class: Voom::Presenters::DSL::Components::Menu

Inherits:
Base
  • Object
show all
Defined in:
lib/voom/presenters/dsl/components/menu.rb

Defined Under Namespace

Classes: Divider, Item

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #context, #id, #type

Instance Method Summary collapse

Methods inherited from Base

#expand!

Methods included from Serializer

#to_hash

Methods included from Lockable

#lock!, #locked?

Constructor Details

#initialize(title = nil, **attribs_, &block) ⇒ Menu

Returns a new instance of Menu.



11
12
13
14
15
16
17
18
19
# File 'lib/voom/presenters/dsl/components/menu.rb', line 11

def initialize(title=nil, **attribs_, &block)
  super(type: :menu, **attribs_, &block)
  @title = title
  @items = []
  @position = attribs.delete(:position) || :left
  @color = attribs.delete(:color)
  @open = attributes.delete(:open){false}
  expand!
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



9
10
11
# File 'lib/voom/presenters/dsl/components/menu.rb', line 9

def color
  @color
end

#itemsObject

Returns the value of attribute items.



9
10
11
# File 'lib/voom/presenters/dsl/components/menu.rb', line 9

def items
  @items
end

#openObject

Returns the value of attribute open.



9
10
11
# File 'lib/voom/presenters/dsl/components/menu.rb', line 9

def open
  @open
end

#positionObject

Returns the value of attribute position.



9
10
11
# File 'lib/voom/presenters/dsl/components/menu.rb', line 9

def position
  @position
end

#titleObject

Returns the value of attribute title.



9
10
11
# File 'lib/voom/presenters/dsl/components/menu.rb', line 9

def title
  @title
end

Instance Method Details

#divider(**attribs, &block) ⇒ Object



28
29
30
31
32
# File 'lib/voom/presenters/dsl/components/menu.rb', line 28

def divider(**attribs, &block)
  @items << Divider.new(parent: self,
                        context: context,
                        **attribs, &block)
end

#item(first_text = nil, text: nil, **attribs, &block) ⇒ Object



21
22
23
24
25
26
# File 'lib/voom/presenters/dsl/components/menu.rb', line 21

def item(first_text = nil, text: nil, **attribs, &block)
  the_text = first_text || text
  @items << Item.new(parent: self, text: the_text,
                     context: context,
                     **attribs, &block)
end