Class: GhostWheel::Expression::Query

Inherits:
GhostWheel::Expression show all
Defined in:
lib/ghost_wheel/expression/query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from GhostWheel::Expression

#parse

Constructor Details

#initialize(expression, &query) ⇒ Query

Returns a new instance of Query.



6
7
8
9
# File 'lib/ghost_wheel/expression/query.rb', line 6

def initialize(expression, &query)
  @expression = expression
  @query      = query
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



11
12
13
# File 'lib/ghost_wheel/expression/query.rb', line 11

def expression
  @expression
end

#queryObject (readonly)

Returns the value of attribute query.



11
12
13
# File 'lib/ghost_wheel/expression/query.rb', line 11

def query
  @query
end

Instance Method Details

#==(other) ⇒ Object



27
28
29
# File 'lib/ghost_wheel/expression/query.rb', line 27

def ==(other)
  super and @expression == other.expression and @query == other.query
end

#uncached_parse(scanner, cache) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ghost_wheel/expression/query.rb', line 13

def uncached_parse(scanner, cache)
  result = @expression.parse(scanner, cache)
  if result.is_a? FailedParseResult
    result
  else
    value = result.is_a?(ParseResult) ? result.value : result
    if @query[value]
      result
    else
      FailedParseResult.instance
    end
  end
end