Class: EverydayMenu::EverydayCommand
- Inherits:
-
Object
- Object
- EverydayMenu::EverydayCommand
- Defined in:
- lib/everyday-menu/utils.rb
Instance Attribute Summary collapse
- #canExecute ⇒ Object
-
#command_id ⇒ Object
readonly
Returns the value of attribute command_id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #canExecuteBlock(&block) ⇒ Object
- #execute(sender) ⇒ Object
-
#initialize(parent, label, command_id = nil, canExecute = true, &block) ⇒ EverydayCommand
constructor
A new instance of EverydayCommand.
Constructor Details
#initialize(parent, label, command_id = nil, canExecute = true, &block) ⇒ EverydayCommand
Returns a new instance of EverydayCommand.
6 7 8 9 10 11 12 13 |
# File 'lib/everyday-menu/utils.rb', line 6 def initialize(parent, label, command_id = nil, canExecute = true, &block) @parent = parent @label = label @block = block @command_id = command_id @canExecute = canExecute @canExecuteBlock = nil end |
Instance Attribute Details
#canExecute ⇒ Object
20 21 22 |
# File 'lib/everyday-menu/utils.rb', line 20 def canExecute @canExecuteBlock.nil? ? @canExecute : @canExecuteBlock.call(self) end |
#command_id ⇒ Object (readonly)
Returns the value of attribute command_id.
3 4 5 |
# File 'lib/everyday-menu/utils.rb', line 3 def command_id @command_id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
3 4 5 |
# File 'lib/everyday-menu/utils.rb', line 3 def label @label end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
3 4 5 |
# File 'lib/everyday-menu/utils.rb', line 3 def parent @parent end |
Instance Method Details
#canExecuteBlock(&block) ⇒ Object
15 16 17 18 |
# File 'lib/everyday-menu/utils.rb', line 15 def canExecuteBlock(&block) @canExecuteBlock = block self end |
#execute(sender) ⇒ Object
24 25 26 |
# File 'lib/everyday-menu/utils.rb', line 24 def execute(sender) @block.call(self, sender) end |