Class: Cyrel::Expression::PatternComprehension

Inherits:
Base
  • Object
show all
Defined in:
lib/cyrel/expression/pattern_comprehension.rb

Overview

Represents a Pattern Comprehension in Cypher. Syntax: [ pattern WHERE condition | expression ] Simplified version for now: [ pattern | expression ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#!=, #%, #&, #*, #+, #-, #/, #<, #<=, #==, #=~, #>, #>=, #^, #|

Constructor Details

#initialize(pattern, projection_expression) ⇒ PatternComprehension

Returns a new instance of PatternComprehension.

Parameters:



15
16
17
18
19
20
21
# File 'lib/cyrel/expression/pattern_comprehension.rb', line 15

def initialize(pattern, projection_expression)
  Cyrel::Pattern.assert_pattern!(pattern, 'Pattern Comprehension')

  @pattern = pattern
  @projection_expression = Expression.coerce(projection_expression)
  # @where_condition = where_condition ? Expression.coerce(where_condition) : nil
end

Instance Attribute Details

#patternObject (readonly)

TODO: Add where_condition



9
10
11
# File 'lib/cyrel/expression/pattern_comprehension.rb', line 9

def pattern
  @pattern
end

#projection_expressionObject (readonly)

TODO: Add where_condition



9
10
11
# File 'lib/cyrel/expression/pattern_comprehension.rb', line 9

def projection_expression
  @projection_expression
end

Instance Method Details

#render(query) ⇒ String

Renders the pattern comprehension expression.

Parameters:

  • query (Cyrel::Query)

    The query object for rendering pattern and expression.

Returns:

  • (String)

    The Cypher string fragment.



26
27
28
29
30
31
32
# File 'lib/cyrel/expression/pattern_comprehension.rb', line 26

def render(query)
  pattern_str = @pattern.render(query)
  # where_str = @where_condition ? " WHERE #{@where_condition.render(query)}" : ""
  projection_str = @projection_expression.render(query)

  "[#{pattern_str} | #{projection_str}]" # Simplified: missing WHERE support
end