Class: RPath::VertexArrayExpression Abstract

Inherits:
Expression show all
Defined in:
lib/rpath/expressions.rb

Overview

This class is abstract.

An expression that evaluates to a vertex array A

Direct Known Subclasses

Adjacent, Named, Where

Instance Method Summary collapse

Methods inherited from Expression

#eval

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

Constructs an At that evaluates to the first vertex in A; forwards the method invocation to this At. Enables omitting the indexer in expressions like RPath { foo.bar }.



137
138
139
# File 'lib/rpath/expressions.rb', line 137

def method_missing(name, *args, &block)
  self[0].send name, *args, &block
end

Instance Method Details

#[](index) ⇒ At #[](conditions) ⇒ Where #[](attribute) ⇒ Attribute

Overloads:

  • #[](index) ⇒ At

    Returns an expression that evaluates to the vertex at index index in A.

    Parameters:

    • index (Integer)

    Returns:

  • #[](conditions) ⇒ Where

    Returns an expression that evaluates to the vertices in A meeting certain conditions.

    Parameters:

    • conditions (Hash)

    Returns:

    See Also:

  • #[](attribute) ⇒ Attribute

    Returns an expression that evaluates to the value of an attribute of the first vertex in A. Enables omitting the indexer in RPath { foo }

    Parameters:

    • attribute (String, Symbol)

    Returns:

Raises:

  • (ArgumentError)

    subscript is not an Integer, Hash, String, or Symbol



121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/rpath/expressions.rb', line 121

def [](subscript)
  case subscript
  when Integer
    At.new self, subscript
  when Hash
    Where.new self, subscript
  when String, Symbol
    self[0][subscript]
  else
    raise ArgumentError, "Subscript for expression producing a vertex must be an Integer, Hash, String, or Symbol"
  end
end

#named(name) ⇒ Named

Returns an expression that evaluates to the vertices in A named name.

Parameters:

  • name (String)

Returns:



98
99
100
# File 'lib/rpath/expressions.rb', line 98

def named(name)
  Named.new self, name
end

#where(*args, &block) ⇒ Where

Returns an expression that evaluates to the vertices in A meeting certain conditions.

Returns:

See Also:



91
92
93
# File 'lib/rpath/expressions.rb', line 91

def where(*args, &block)
  Where.new self, *args, &block
end