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_configuration(matcher, configuration) ⇒ 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 @configurations = [] @modifications = [] end |
Instance Method Details
#add_configuration(matcher, configuration) ⇒ Object
10 11 12 |
# File 'lib/widgets/base/manager.rb', line 10 def add_configuration(matcher, configuration) @configurations.push([matcher, configuration]) end |
#add_modification(matcher, &callback) ⇒ Object
14 15 16 |
# File 'lib/widgets/base/manager.rb', line 14 def add_modification(matcher, &callback) @modifications.push([matcher, callback]) end |
#configurations(widget) ⇒ Object
18 19 20 21 22 |
# File 'lib/widgets/base/manager.rb', line 18 def configurations() @configurations.filter_map do |(matcher, config)| config if .check_match(matcher) end end |
#execute_modifications(widget) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/widgets/base/manager.rb', line 24 def execute_modifications() @modifications.each do |(matcher, callback)| next unless (match = .check_match(matcher)) arguments = match.is_a?(MatchData) ? [, match] : [] callback.call(*arguments) end end |