Class: DrinkMenu::MenuItem
- Inherits:
-
Object
- Object
- DrinkMenu::MenuItem
- Extended by:
- Forwardable
- Defined in:
- lib/drink-menu/menu_item.rb
Constant Summary
Constants included from Forwardable
Forwardable::FORWARDABLE_VERSION
Instance Attribute Summary collapse
-
#canExecuteSignal ⇒ Object
Returns the value of attribute canExecuteSignal.
-
#command ⇒ Object
Returns the value of attribute command.
-
#label ⇒ Object
Returns the value of attribute label.
-
#menuItem ⇒ Object
Returns the value of attribute menuItem.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(menuItem = nil) ⇒ MenuItem
constructor
A new instance of MenuItem.
- #subscribe(&block) ⇒ Object
Methods included from Forwardable
def_instance_delegator, def_instance_delegators, instance_delegate
Constructor Details
#initialize(menuItem = nil) ⇒ MenuItem
Returns a new instance of MenuItem.
66 67 68 |
# File 'lib/drink-menu/menu_item.rb', line 66 def initialize(=nil) @menuItem = || NSMenuItem.alloc.init end |
Instance Attribute Details
#canExecuteSignal ⇒ Object
Returns the value of attribute canExecuteSignal.
5 6 7 |
# File 'lib/drink-menu/menu_item.rb', line 5 def canExecuteSignal @canExecuteSignal end |
#command ⇒ Object
Returns the value of attribute command.
5 6 7 |
# File 'lib/drink-menu/menu_item.rb', line 5 def command @command end |
#label ⇒ Object
Returns the value of attribute label.
5 6 7 |
# File 'lib/drink-menu/menu_item.rb', line 5 def label @label end |
#menuItem ⇒ Object
Returns the value of attribute menuItem.
5 6 7 |
# File 'lib/drink-menu/menu_item.rb', line 5 def @menuItem end |
Class Method Details
.itemWithLabel(label, &block) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/drink-menu/menu_item.rb', line 35 def self.itemWithLabel(label, title: title) new.tap do |item| item.label = label item.title = title end end |
.separatorItem ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/drink-menu/menu_item.rb', line 57 def self.separatorItem @@separatorId ||= 0 @@separatorId += 1 label = :"separator#{@@separatorId}" new(NSMenuItem.separatorItem).tap do |item| item.label = label end end |
Instance Method Details
#subscribe(&block) ⇒ Object
84 85 86 87 88 |
# File 'lib/drink-menu/menu_item.rb', line 84 def subscribe(&block) command.map(->(value){ [label, self] }).subscribeNext(block) end |