Class: Elastic::Nodes::And
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #add_child(_child) ⇒ Object
- #children=(_value) ⇒ Object
- #clone ⇒ Object
- #render(_options = {}) ⇒ Object
- #simplify ⇒ Object
- #traverse(&_block) ⇒ Object
Methods inherited from Base
Methods included from Support::Traversable
Class Method Details
.build(_children) ⇒ Object
3 4 5 |
# File 'lib/elastic/nodes/and.rb', line 3 def self.build(_children) new.tap { |node| node.children = _children } end |
Instance Method Details
#add_child(_child) ⇒ Object
7 8 9 |
# File 'lib/elastic/nodes/and.rb', line 7 def add_child(_child) @children << _child end |
#children=(_value) ⇒ Object
11 12 13 |
# File 'lib/elastic/nodes/and.rb', line 11 def children=(_value) @children = _value.dup.to_a end |
#clone ⇒ Object
20 21 22 |
# File 'lib/elastic/nodes/and.rb', line 20 def clone prepare_clone super, @children.map(&:clone) end |
#render(_options = {}) ⇒ Object
30 31 32 |
# File 'lib/elastic/nodes/and.rb', line 30 def render( = {}) { operation => @children.map { |c| c.render() } } end |
#simplify ⇒ Object
24 25 26 27 28 |
# File 'lib/elastic/nodes/and.rb', line 24 def simplify new_children = @children.map(&:simplify) return new_children.first if new_children.count == 1 prepare_clone(super, new_children) end |
#traverse(&_block) ⇒ Object
15 16 17 18 |
# File 'lib/elastic/nodes/and.rb', line 15 def traverse(&_block) super @children.each { |c| c.traverse(&_block) } end |