Class: UState::Query

Inherits:
Object
  • Object
show all
Includes:
Beefcake::Message
Defined in:
lib/ustate/query.rb,
lib/ustate/query/or.rb,
lib/ustate/query/and.rb,
lib/ustate/query/not.rb,
lib/ustate/query/less.rb,
lib/ustate/query/node.rb,
lib/ustate/query/true.rb,
lib/ustate/query/false.rb,
lib/ustate/query/equals.rb,
lib/ustate/query/greater.rb,
lib/ustate/query/optimizer.rb,
lib/ustate/query/less_equal.rb,
lib/ustate/query/not_equals.rb,
lib/ustate/query/approximately.rb,
lib/ustate/query/greater_equal.rb

Defined Under Namespace

Modules: Binarity, Narity Classes: And, Approximately, Equals, False, Greater, GreaterEqual, Less, LessEqual, Node, Not, NotEquals, Optimizer, Or, True

Class Method Summary collapse

Class Method Details

.query(q) ⇒ Object

Converts a Query or string to a query AST.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ustate/query.rb', line 8

def self.query(q)
  case q
  when String
    parser = QueryStringParser.new
    q = parser.parse(q)
    unless q
      raise ArgumentError, "error parsing #{query_string.inspect} at line #{parser.failure_line}:#{parser.failure_column}: #{parser.failure_reason}"
    end
    q.query
  when Query
    query q.string
  else
    raise ArgumentError, "don't know what to do with #{q.class} #{q.inspect}"
  end
end