Class: Smoke::Source::YQL

Inherits:
Origin show all
Defined in:
lib/smoke/source/yql.rb

Overview

YQL will call to Yahoo YQL services

Usage:

Smoke.yql(:ruby) do
  select  :all
  from    "search.web"
  where   :query, "ruby"
end

Constant Summary collapse

API_BASE =
"http://query.yahooapis.com/v1/public/yql"

Instance Attribute Summary collapse

Attributes inherited from Origin

#items, #name

Instance Method Summary collapse

Methods inherited from Origin

#discard, #emit, #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

#requestObject (readonly)

Returns the value of attribute request.



13
14
15
# File 'lib/smoke/source/yql.rb', line 13

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


34
35
36
37
# File 'lib/smoke/source/yql.rb', line 34

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"


23
24
25
26
27
# File 'lib/smoke/source/yql.rb', line 23

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"


55
56
57
# File 'lib/smoke/source/yql.rb', line 55

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"


45
46
47
48
# File 'lib/smoke/source/yql.rb', line 45

def where(column, value)
  @where = @where || []
  @where << "#{column.to_s} = '#{value}'"
end