Class: TkWrapper::Widgets::Base::ComparatorItemStore
- Inherits:
-
Object
- Object
- TkWrapper::Widgets::Base::ComparatorItemStore
- Defined in:
- lib/widgets/base/comparator_item_store.rb
Constant Summary collapse
- Matcher =
TkWrapper::Widgets::Base::Matcher
Instance Method Summary collapse
-
#initialize ⇒ ComparatorItemStore
constructor
A new instance of ComparatorItemStore.
-
#items_and_matches_for_widget(widget) ⇒ Object
returns [[…], match: Match, […], …].
- #push(key, *items) ⇒ Object
Constructor Details
#initialize ⇒ ComparatorItemStore
Returns a new instance of ComparatorItemStore.
8 9 10 11 |
# File 'lib/widgets/base/comparator_item_store.rb', line 8 def initialize @key_map = {} # for fast lookup @comparator_map = {} # for lookup using comparisons by Matcher class end |
Instance Method Details
#items_and_matches_for_widget(widget) ⇒ Object
returns [[…], match: Match, […], …]
22 23 24 25 26 |
# File 'lib/widgets/base/comparator_item_store.rb', line 22 def () .ids.reduce([]) do |items, id| items + items_from_key_map(id) + items_from_comparator_map(id, ) end end |
#push(key, *items) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/widgets/base/comparator_item_store.rb', line 13 def push(key, *items) if [String, Symbol].include?(key) (@key_map[key] ||= []).concat(items) else (@comparator_map[key] ||= []).concat(items) end end |