Class: IceRocket::Search
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #fetch(options = {}) ⇒ Object
-
#initialize(search_term, options = {}) ⇒ Search
constructor
A new instance of Search.
- #params(options = {}) ⇒ Object
Constructor Details
#initialize(search_term, options = {}) ⇒ Search
Returns a new instance of Search.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ice_rocket.rb', line 14 def initialize(search_term, ={}) opts = { :q => search_term, :dh => [:dh] || [:date_high], :dl => [:dl] || [:date_low], :lng => [:lng] || [:language], :n => [:n] || [:per_page] || 10, :sourceid => [:sourceid] } opts[:dh] = opts[:dh].strftime("%m/%d/%Y") if opts[:dh] opts[:dl] = opts[:dl].strftime("%m/%d/%Y") if opts[:dl] self. = opts end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/ice_rocket.rb', line 12 def @options end |
Instance Method Details
#fetch(options = {}) ⇒ Object
30 31 32 |
# File 'lib/ice_rocket.rb', line 30 def fetch(={}) self.class.get('/search', params()) end |
#params(options = {}) ⇒ Object
34 35 36 |
# File 'lib/ice_rocket.rb', line 34 def params(={}) { :query => self..merge( :p => [:p] || [:page] || 1 ) } end |