Class: EverydayMenu::CommandList
- Inherits:
-
Object
- Object
- EverydayMenu::CommandList
- Defined in:
- lib/everyday-menu/utils.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
Instance Method Summary collapse
- #add(command_id = nil, &block) ⇒ Object
- #canExecute ⇒ Object
- #execute(sender) ⇒ Object
-
#initialize(parent, label) ⇒ CommandList
constructor
A new instance of CommandList.
- #last ⇒ Object
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
#label ⇒ Object
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 |
#canExecute ⇒ Object
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 |
#last ⇒ Object
42 43 44 |
# File 'lib/everyday-menu/utils.rb', line 42 def last @items.last end |