Class: EverydayMenu::CommandList

Inherits:
Object
  • Object
show all
Defined in:
lib/everyday-menu/utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, label) ⇒ CommandList

Returns a new instance of CommandList.



32
33
34
35
36
# File 'lib/everyday-menu/utils.rb', line 32

def initialize(parent, label)
  @parent = parent
  @label  = label
  @items  = []
end

Instance Attribute Details

#labelObject

Returns the value of attribute label.



30
31
32
# File 'lib/everyday-menu/utils.rb', line 30

def label
  @label
end

Instance Method Details

#add(command_id = nil, &block) ⇒ Object



38
39
40
# File 'lib/everyday-menu/utils.rb', line 38

def add(command_id = nil, &block)
  @items << EverydayCommand.new(@parent, @label, command_id, &block)
end

#canExecuteObject



50
51
52
# File 'lib/everyday-menu/utils.rb', line 50

def canExecute
  @items.any? { |item| item.canExecute }
end

#execute(sender) ⇒ Object



46
47
48
# File 'lib/everyday-menu/utils.rb', line 46

def execute(sender)
  @items.each { |item| item.execute(sender) }
end

#lastObject



42
43
44
# File 'lib/everyday-menu/utils.rb', line 42

def last
  @items.last
end