Class: Elastic::Nodes::And

Inherits:
Base
  • Object
show all
Defined in:
lib/elastic/nodes/and.rb

Direct Known Subclasses

Or

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #handle_result

Methods included from Support::Traversable

#pick_nodes

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

#cloneObject



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(_options = {})
  { operation => @children.map { |c| c.render(_options) } }
end

#simplifyObject



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