Class: Cyrel::Clause::Skip

Inherits:
Base
  • Object
show all
Defined in:
lib/cyrel/clause/skip.rb

Overview

Represents a SKIP clause in a Cypher query.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount) ⇒ Skip

Initializes a SKIP clause.

Parameters:

  • amount (Integer, Cyrel::Expression::Base, Object)

    The number of results to skip. Can be an integer literal or an expression that evaluates to an integer (typically a parameter).



13
14
15
16
17
# File 'lib/cyrel/clause/skip.rb', line 13

def initialize(amount)
  @amount = Expression.coerce(amount)
  # Could add validation here to ensure the expression likely returns an integer,
  # but Cypher itself will handle runtime errors.
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



7
8
9
# File 'lib/cyrel/clause/skip.rb', line 7

def amount
  @amount
end

Instance Method Details

#render(query) ⇒ String

Renders the SKIP clause.

Parameters:

  • query (Cyrel::Query)

    The query object for rendering the amount expression.

Returns:

  • (String)

    The Cypher string fragment for the clause.



22
23
24
# File 'lib/cyrel/clause/skip.rb', line 22

def render(query)
  "SKIP #{@amount.render(query)}"
end

#replace!(other_skip) ⇒ Object

Merging SKIP typically replaces the existing value.

Parameters:



28
29
30
31
# File 'lib/cyrel/clause/skip.rb', line 28

def replace!(other_skip)
  @amount = other_skip.amount
  self
end