Class: Squeel::Nodes::Nary
- Inherits:
-
Object
- Object
- Squeel::Nodes::Nary
- Includes:
- PredicateOperators
- Defined in:
- lib/squeel/nodes/nary.rb
Overview
A node containing multiple children. Just the And node for now.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#children ⇒ Array
readonly
This node’s children.
Instance Method Summary collapse
-
#&(other) ⇒ Nary
Add a new child to the node’s children.
-
#-(other) ⇒ Nary
Append a new Not node to this node’s children.
-
#eql?(other) ⇒ Boolean
(also: #==)
Object comparison.
-
#initialize(children) ⇒ Nary
constructor
Creates a new Nary node with the given array of children.
Methods included from PredicateOperators
Constructor Details
#initialize(children) ⇒ Nary
Creates a new Nary node with the given array of children
12 13 14 15 16 17 18 |
# File 'lib/squeel/nodes/nary.rb', line 12 def initialize(children) raise ArgumentError, '#{self.class} requires an array' unless Array === children # We don't dup here, as incoming arrays should be created by the # PredicateOperators#& method on other nodes. If you're creating And nodes # manually, by sure that they're new arays. @children = children end |
Instance Attribute Details
#children ⇒ Array (readonly)
Returns This node’s children.
8 9 10 |
# File 'lib/squeel/nodes/nary.rb', line 8 def children @children end |
Instance Method Details
#&(other) ⇒ Nary
Add a new child to the node’s children
23 24 25 26 |
# File 'lib/squeel/nodes/nary.rb', line 23 def &(other) @children << other self end |
#-(other) ⇒ Nary
Append a new Not node to this node’s children
31 32 33 34 |
# File 'lib/squeel/nodes/nary.rb', line 31 def -(other) @children << Not.new(other) self end |
#eql?(other) ⇒ Boolean Also known as: ==
Object comparison
37 38 39 40 |
# File 'lib/squeel/nodes/nary.rb', line 37 def eql?(other) self.class == other.class && self.children == other.children end |