Class: EverydayMenu::EverydayCommand

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, 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

#canExecuteObject



20
21
22
# File 'lib/everyday-menu/utils.rb', line 20

def canExecute
  @canExecuteBlock.nil? ? @canExecute : @canExecuteBlock.call(self)
end

#command_idObject (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

#labelObject (readonly)

Returns the value of attribute label.



3
4
5
# File 'lib/everyday-menu/utils.rb', line 3

def label
  @label
end

#parentObject (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