Module: Elastic::Support::Traversable
- Included in:
- Nodes::Base, Results::Base, Elastic::Shims::Base
- Defined in:
- lib/elastic/support/traversable.rb
Instance Method Summary collapse
Instance Method Details
#pick_nodes(*_types, &_block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/elastic/support/traversable.rb', line 7 def pick_nodes(*_types, &_block) if _types.empty? enum = Enumerator.new do |y| traverse { |h| y << h } end else enum = Enumerator.new do |y| traverse { |h| y << h if _types.any? { |t| h.is_a? t } } end end return enum if _block.nil? enum.each(&_block) end |
#traverse(&_block) ⇒ Object
3 4 5 |
# File 'lib/elastic/support/traversable.rb', line 3 def traverse(&_block) raise NotImplementedError, "every traversable tree must implement 'traverse'" end |