Class: Factual::Query::Table
Constant Summary collapse
- DEFAULT_LIMIT =
20
- VALID_PARAMS =
[ :filters, :search, :geo, :sort, :select, :limit, :offset, :threshold, :include_count, :user ]
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(api, path, params = {}) ⇒ Table
constructor
A new instance of Table.
- #page(page_number, paging_options = {}) ⇒ Object
- #row(factual_id) ⇒ Object
- #sort_asc(*args) ⇒ Object
- #sort_desc(*args) ⇒ Object
Methods inherited from Base
#[], #data, #each, #full_path, #last, #populate, #rows, #schema, #total_count
Constructor Details
#initialize(api, path, params = {}) ⇒ Table
Returns a new instance of Table.
13 14 15 16 17 |
# File 'lib/factual/query/table.rb', line 13 def initialize(api, path, params = {}) @path = path @action = :read super(api, params) end |
Instance Method Details
#page(page_number, paging_options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/factual/query/table.rb', line 35 def page(page_number, = {}) limit = ([:per] || ["per"] || DEFAULT_LIMIT).to_i limit = DEFAULT_LIMIT if limit < 1 page_number = page_number.to_i page_number = 1 if page_number < 1 offset = (page_number - 1) * limit Table.new(@api, @path, @params.merge(:limit => limit, :offset => offset)) end |
#row(factual_id) ⇒ Object
46 47 48 49 50 |
# File 'lib/factual/query/table.rb', line 46 def row(factual_id) @path += "/#{factual_id}" @params = {} return self.first end |