class Ranking
Attributes
options[R]
Public Class Methods
new(*options)
click to toggle source
# File lib/uk_ranking.rb, line 16 def initialize(*options) # keyword, url, limit self.options = options.extract_options! end
Public Instance Methods
from()
click to toggle source
# File lib/uk_ranking.rb, line 26 def from validate_options @finder ||= Finder.new @finder.find(@options) end
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# 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
options=(options)
click to toggle source
# File lib/uk_ranking.rb, line 20 def options=(options) @options = @@default_options.merge(options) @options[:url].gsub!(/(http:\/\/|https:\/\/)/, '') @options[:url].gsub!(/^www/, '') end
Protected Instance Methods
validate_options()
click to toggle source
# File lib/uk_ranking.rb, line 43 def validate_options raise "Keyword and site parameters must be Strings" unless @options[:keyword].is_a?(String) and @options[:url].is_a?(String) raise "Engine should be 'bing', 'google' or 'yahoo'" unless @@default_options[:supported_engines].include?(@options[:engine].to_sym) end