Class: TkWrapper::Util::Tk::Finder
- Inherits:
-
Object
- Object
- TkWrapper::Util::Tk::Finder
- Defined in:
- lib/util/tk/finder.rb
Constant Summary collapse
- Match =
TkWrapper::Widgets::Base::Match
- Matcher =
TkWrapper::Widgets::Base::Matcher
- Matches =
TkWrapper::Widgets::Base::Matches
Instance Method Summary collapse
- #find(comparators, widgets = @widgets, lookup = @lookup) ⇒ Object
- #find_all(comparators, widgets = @widgets, lookup = @lookup) ⇒ Object
-
#initialize(widgets: nil, lookup: nil) ⇒ Finder
constructor
A new instance of Finder.
- #iter(comparators, widgets = @widgets, lookup = @lookup) ⇒ Object
Constructor Details
#initialize(widgets: nil, lookup: nil) ⇒ Finder
Returns a new instance of Finder.
12 13 14 15 |
# File 'lib/util/tk/finder.rb', line 12 def initialize(widgets: nil, lookup: nil) @lookup = lookup @widgets = end |
Instance Method Details
#find(comparators, widgets = @widgets, lookup = @lookup) ⇒ Object
25 26 27 |
# File 'lib/util/tk/finder.rb', line 25 def find(comparators, = @widgets, lookup = @lookup) iter(comparators, , lookup, &:itself).first end |
#find_all(comparators, widgets = @widgets, lookup = @lookup) ⇒ Object
29 30 31 32 |
# File 'lib/util/tk/finder.rb', line 29 def find_all(comparators, = @widgets, lookup = @lookup) it = iter(comparators, , lookup, &:itself) it.each_with_object(Matches.new) { |match, matches| matches.push(match) } end |
#iter(comparators, widgets = @widgets, lookup = @lookup) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/util/tk/finder.rb', line 17 def iter(comparators, = @widgets, lookup = @lookup) comparators = [comparators] unless comparators.is_a?(Array) Enumerator.new do |y| comparators = (lookup, comparators) { |m| y << m } (, comparators) { |m| y << m } end end |