Class: Zillabyte::API::Queries

Inherits:
Base
  • Object
show all
Defined in:
lib/zillabyte/api/queries.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #request

Constructor Details

This class inherits a constructor from Zillabyte::API::Base

Instance Method Details

#agnostic(expression, options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/zillabyte/api/queries.rb', line 44

def agnostic(expression, options = {})
  case expression
  when Array
    return sxp(expression, options)
  when String
    return sql(expression, options)
  else
    throw "unknown expression type: #{expression}"
  end
end

#sql(expression, options = {}) ⇒ Object

GET /sql



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/zillabyte/api/queries.rb', line 25

def sql(expression, options = {})

  options = {
    'sql' => expression
  }.merge(options)
  
  res = request(
    :expects  => 200,
    :method   => :post,
    :path     => "/query_sql",
    :body     => options.to_json
  )
  
  res.body

end

#sxp(expression, options = {}) ⇒ Object

GET /sxp



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/zillabyte/api/queries.rb', line 5

def sxp(expression, options = {})

  options = {
    'sxp' => expression
  }.merge(options)
  
  res = request(
    :expects  => 200,
    :method   => :post,
    :path     => "/query_sxp",
    :body     => options.to_json
  )
  
  res.body

end