Class: RPath::Where

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

Overview

Given a prior expression producing vertex array A, evaluates to an array containing the vertices in A that match certain conditions.

Instance Method Summary collapse

Methods inherited from VertexArrayExpression

#[], #method_missing, #named, #where

Methods inherited from Expression

#eval

Constructor Details

#initialize(prior, conditions) ⇒ Where #initialize(prior) {|vertex| ... } ⇒ Where

Returns a new instance of Where.

Overloads:

  • #initialize(prior, conditions) ⇒ Where

    Parameters:

    • prior (Expression)

      An expression that evaluates to a vertex array

    • conditions (Hash{Symbol => Object})

      A map of attribute keys to values.

  • #initialize(prior) {|vertex| ... } ⇒ Where

    Parameters:

    • prior (Expression)

      An expression that evaluates to a vertex array

    Yield Parameters:

    • vertex (Object)

    Yield Returns:

    • (Boolean)

      Whether the vertex should be selected



222
223
224
225
226
227
# File 'lib/rpath/expressions.rb', line 222

def initialize(prior, conditions = {}, &selector)
  super()
  @prior = prior
  @selector = block_given? ? selector : nil
  @conditions = block_given? ? nil : conditions
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RPath::VertexArrayExpression

Instance Method Details

#to_sString

Returns:

  • (String)


230
231
232
233
234
235
236
# File 'lib/rpath/expressions.rb', line 230

def to_s
  conditions = @selector ?
    'selector' :
    @conditions.map { |k, v| "#{k}: #{v}" }.join(', ')

  "#{@prior}[#{conditions}]"
end