Class: Smoke::YQL
Overview
Constant Summary collapse
- API_BASE =
"http://query.yahooapis.com/v1/public/yql"
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Attributes inherited from Origin
#exposed, #items, #name, #requirements
Instance Method Summary collapse
-
#from(source) ⇒ Object
from corresponds to the from fragment of the YQL query Usage: from “search.web” or from :html.
-
#select(what = :all) ⇒ Object
Select indicates what YQL will be selecting Usage: select :all => “SELECT *” select :title => “SELECT title” select :title, :description => “SELECT title, description”.
-
#use(url) ⇒ Object
‘use` can be used to set the url location of the data-table that you want YQL to search upon.
-
#where(column, value) ⇒ Object
where is a straight up match, no fancy matchers are currently supported Usage: where :xpath, “//div/div/a” or where :query, “python”.
Methods inherited from Origin
#conceal, #concealed?, #discard, #emit, #expose, #exposed?, #initialize, #insert, #keep, #method_missing, #output, #path, #prepare, #rename, #reverse, #sort, #transform, #truncate
Constructor Details
This class inherits a constructor from Smoke::Origin
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Smoke::Origin
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
12 13 14 |
# File 'lib/smoke/source/yql.rb', line 12 def request @request end |
Instance Method Details
#from(source) ⇒ Object
from corresponds to the from fragment of the YQL query Usage:
from "search.web"
or
from :html
33 34 35 36 |
# File 'lib/smoke/source/yql.rb', line 33 def from(source) @from = source.join(',') and return if source.is_a? Array @from = source.to_s end |
#select(what = :all) ⇒ Object
Select indicates what YQL will be selecting Usage:
select :all
=> "SELECT *"
select :title
=> "SELECT title"
select :title, :description
=> "SELECT title, description"
22 23 24 25 26 |
# File 'lib/smoke/source/yql.rb', line 22 def select(what = :all) @select = what.join(",") and return if what.is_a? Array @select = "*" and return if what == :all @select = what and return end |
#use(url) ⇒ Object
‘use` can be used to set the url location of the data-table that you want YQL to search upon
Usage:
use "http://datatables.org/alltables.env"
53 54 55 |
# File 'lib/smoke/source/yql.rb', line 53 def use(url) params.merge!({:env => url}) end |
#where(column, value) ⇒ Object
where is a straight up match, no fancy matchers are currently supported Usage:
where :xpath, "//div/div/a"
or
where :query, "python"
44 45 46 |
# File 'lib/smoke/source/yql.rb', line 44 def where(column, value) (@where||=[]) << "#{column.to_s} = '#{value}'" end |