Class: NodeQuery::Compiler::ArrayValue

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/node_query/compiler/array_value.rb

Overview

ArrayValue represents a ruby array value.

Constant Summary

Constants included from Comparable

Comparable::ARRAY_VALID_OPERATORS, Comparable::NUMBER_VALID_OPERATORS, Comparable::REGEXP_VALID_OPERATORS, Comparable::SIMPLE_VALID_OPERATORS, Comparable::STRING_VALID_OPERATORS

Instance Method Summary collapse

Methods included from Comparable

#actual_value, #is_equal?, #match?, #valid_operator?

Constructor Details

#initialize(value: nil, rest: nil) ⇒ ArrayValue

Initialize an Array.

Parameters:

  • value (defaults to: nil)

    the first value of the array

  • rest (defaults to: nil)

    the rest value of the array



11
12
13
14
# File 'lib/node_query/compiler/array_value.rb', line 11

def initialize(value: nil, rest: nil)
  @value = value
  @rest = rest
end

Instance Method Details

#expected_value(base_node) ⇒ Array

Get the expected value.

Returns:

  • (Array)


18
19
20
21
22
23
# File 'lib/node_query/compiler/array_value.rb', line 18

def expected_value(base_node)
  expected = []
  expected.push(@value) if @value
  expected += @rest.expected_value(base_node) if @rest
  expected
end

#to_sObject



31
32
33
# File 'lib/node_query/compiler/array_value.rb', line 31

def to_s
  [@value, @rest].compact.join(' ')
end

#valid_operatorsArray

Get valid operators.

Returns:

  • (Array)

    valid operators



27
28
29
# File 'lib/node_query/compiler/array_value.rb', line 27

def valid_operators
  ARRAY_VALID_OPERATORS
end