Class: TkWrapper::Widgets::Base::Manager
- Inherits:
-
Object
- Object
- TkWrapper::Widgets::Base::Manager
- Defined in:
- lib/widgets/base/manager.rb
Overview
manages widgets and their global configurations
Instance Method Summary collapse
- #add_configurations(matcher = nil, config = nil, **configs) ⇒ Object
- #add_modification(matcher, &callback) ⇒ Object
- #configurations(widget) ⇒ Object
- #execute_modifications(widget) ⇒ Object
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
Constructor Details
#initialize ⇒ Manager
Returns a new instance of Manager.
5 6 7 8 |
# File 'lib/widgets/base/manager.rb', line 5 def initialize @configuration_matchers = { regex: {}, map: {} } @modification_matchers = { regex: {}, map: {} } end |
Instance Method Details
#add_configurations(matcher = nil, config = nil, **configs) ⇒ Object
10 11 12 13 14 |
# File 'lib/widgets/base/manager.rb', line 10 def add_configurations(matcher = nil, config = nil, **configs) add_matcher(matcher, config, @configuration_matchers) if config configs.each { |mat, cfg| add_matcher(mat, cfg, @configuration_matchers) } end |
#add_modification(matcher, &callback) ⇒ Object
16 17 18 |
# File 'lib/widgets/base/manager.rb', line 16 def add_modification(matcher, &callback) add_matcher(matcher, callback, @modification_matchers) end |
#configurations(widget) ⇒ Object
20 21 22 23 |
# File 'lib/widgets/base/manager.rb', line 20 def configurations() configs = find_matching_items(.ids, @configuration_matchers) configs.map { |config| config[0] } end |
#execute_modifications(widget) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/widgets/base/manager.rb', line 25 def execute_modifications() callbacks = find_matching_items(.ids, @modification_matchers) callbacks.each do |callback| callback, match = callback match ? callback.call(, match) : callback.call() end end |