Class: RPath::VertexExpression Abstract

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

Overview

This class is abstract.

An expression that evaluates to a vertex V

Direct Known Subclasses

At, Root

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) ⇒ Named

Returns an expression that evaluates to V’s adjacent vertices named name. Enables the basic RPath expression RPath { foo }.

Returns:



78
79
80
# File 'lib/rpath/expressions.rb', line 78

def method_missing(name, *args, &block)
  Named.new adjacent, name.to_s
end

Instance Method Details

#[](subscript) ⇒ Attribute

Returns an expression that evaluates to the value of an attribute of V

Returns:

Raises:

  • (ArgumentError)

    subscript is not a String or Symbol



68
69
70
71
72
73
# File 'lib/rpath/expressions.rb', line 68

def [](subscript)
  unless subscript.is_a?(String) || subscript.is_a?(Symbol)
    raise ArgumentError, "Subscript for expression producing a vertex must by a String or Symbol"
  end
  Attribute.new self, subscript
end

#adjacentAdjacent

Returns an expression that evaluates to V’s adjacent vertices.

Returns:



54
55
56
# File 'lib/rpath/expressions.rb', line 54

def adjacent
  Adjacent.new self
end

#contentContent

Returns an expression that evaluates to V’s content.

Returns:



60
61
62
# File 'lib/rpath/expressions.rb', line 60

def content
  Content.new self
end