Class: Factual::Query::Base

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/factual/query/base.rb

Direct Known Subclasses

Crosswalk, Resolve, Table

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

#actionObject (readonly)

Returns the value of attribute action.



11
12
13
# File 'lib/factual/query/base.rb', line 11

def action
  @action
end

#paramsObject (readonly)

Returns the value of attribute params.



11
12
13
# File 'lib/factual/query/base.rb', line 11

def params
  @params
end

#pathObject (readonly)

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

#each(&block) ⇒ Object



13
14
15
# File 'lib/factual/query/base.rb', line 13

def each(&block)
  rows.each { |row| block.call(row) }
end

#lastObject



17
18
19
# File 'lib/factual/query/base.rb', line 17

def last
  rows.last
end

#rowsObject



25
26
27
# File 'lib/factual/query/base.rb', line 25

def rows
  response["data"]
end

#schemaObject



33
34
35
# File 'lib/factual/query/base.rb', line 33

def schema
  @schema ||= @api.schema(self)
end

#total_rowsObject



29
30
31
# File 'lib/factual/query/base.rb', line 29

def total_rows
  response["total_row_count"]
end