Class: Factual::Query::Base
- Inherits:
-
Object
- Object
- Factual::Query::Base
show all
- Includes:
- Enumerable
- Defined in:
- lib/factual/query/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(api, params) ⇒ Base
Returns a new instance of Base.
6
7
8
9
|
# File 'lib/factual/query/base.rb', line 6
def initialize(api, params)
@api = api
@params = params
end
|
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
11
12
13
|
# File 'lib/factual/query/base.rb', line 11
def action
@action
end
|
#params ⇒ Object
Returns the value of attribute params.
11
12
13
|
# File 'lib/factual/query/base.rb', line 11
def params
@params
end
|
#path ⇒ Object
Returns the value of attribute path.
11
12
13
|
# File 'lib/factual/query/base.rb', line 11
def path
@path
end
|
Instance Method Details
#[](index) ⇒ Object
21
22
23
|
# File 'lib/factual/query/base.rb', line 21
def [](index)
rows[index]
end
|
#data ⇒ Object
25
26
27
|
# File 'lib/factual/query/base.rb', line 25
def data
response["data"]
end
|
#each(&block) ⇒ Object
13
14
15
|
# File 'lib/factual/query/base.rb', line 13
def each(&block)
rows.each { |row| block.call(row) }
end
|
#full_path ⇒ Object
TODO move to Multiable module, and support multi writes
43
44
45
|
# File 'lib/factual/query/base.rb', line 43
def full_path
@api.full_path(@action, @path, @params)
end
|
#last ⇒ Object
17
18
19
|
# File 'lib/factual/query/base.rb', line 17
def last
rows.last
end
|
#populate(query_response) ⇒ Object
47
48
49
|
# File 'lib/factual/query/base.rb', line 47
def populate(query_response)
@response = query_response
end
|
#rows ⇒ Object
29
30
31
|
# File 'lib/factual/query/base.rb', line 29
def rows
data
end
|
#schema ⇒ Object
38
39
40
|
# File 'lib/factual/query/base.rb', line 38
def schema
@schema ||= @api.schema(self)
end
|
#total_count ⇒ Object
33
34
35
36
|
# File 'lib/factual/query/base.rb', line 33
def total_count
resp = @api.get(self, :include_count => true, :limit => 1)
resp["total_row_count"]
end
|