Class: EverydayMenu::DynamicTitle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(getter, item_parent, item, title) ⇒ DynamicTitle

Returns a new instance of DynamicTitle.



4
5
6
7
8
9
10
11
# File 'lib/everyday-menu/menu_item.rb', line 4

def initialize(getter, item_parent, item, title)
  @getter = getter
  @item_parent = item_parent
  @item = item
  @title = title
  @item.bind('title', toObject: self, withKeyPath: 'title', options: { 'NSContinuouslyUpdatesValue' => true })
  @item.bind(NSEnabledBinding, toObject: @item_parent.commands, withKeyPath: 'canExecute', options: nil)
end

Instance Attribute Details

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#updateObject



12
13
14
# File 'lib/everyday-menu/menu_item.rb', line 12

def update
  self.performSelectorOnMainThread('title=:', withObject: @getter.call, waitUntilDone: false)
end