Class: Ranking
- Inherits:
-
Object
- Object
- Ranking
- Defined in:
- lib/uk_ranking.rb
Constant Summary collapse
- @@default_options =
careful, res_per_page doesn’t work with more than 10 for all search engines!
{ :limit => 200, :res_per_page => 10, :supported_engines => [:bing, :google, :googleUS, :yahoo] }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #from ⇒ Object
-
#initialize(*options) ⇒ Ranking
constructor
keyword, url, limit.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(*options) ⇒ Ranking
keyword, url, limit
16 17 18 |
# File 'lib/uk_ranking.rb', line 16 def initialize(*) # keyword, url, limit self. = . end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/uk_ranking.rb', line 32 def method_missing(method, *args, &block) engine = @@default_options[:supported_engines].find{ |name| ("from_" << name.to_s).match /#{method}/ } if engine @options.merge!({:engine => engine}) send("from") else super(method, *args, &block) end end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/uk_ranking.rb', line 14 def @options end |
Instance Method Details
#from ⇒ Object
26 27 28 29 30 |
# File 'lib/uk_ranking.rb', line 26 def from @finder ||= Finder.new @finder.find(@options) end |