Class: Cyrel::Pattern::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/cyrel/pattern/path.rb

Overview

Represents a linear path pattern in a Cypher query, consisting of an alternating sequence of Node and Relationship objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elements) ⇒ Path

Returns a new instance of Path.

Parameters:



12
13
14
15
# File 'lib/cyrel/pattern/path.rb', line 12

def initialize(elements)
  validate_elements(elements)
  @elements = elements
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



8
9
10
# File 'lib/cyrel/pattern/path.rb', line 8

def elements
  @elements
end

Instance Method Details

#render(query) ⇒ String

Renders the path pattern part of the Cypher query.

Parameters:

  • query (Cyrel::Query)

    The query object, used for parameter registration.

Returns:

  • (String)

    The Cypher string fragment for the path pattern.



20
21
22
# File 'lib/cyrel/pattern/path.rb', line 20

def render(query)
  @elements.map { |element| element.render(query) }.join
end