Class: Google::Reader::Search
- Defined in:
- lib/google/reader/search.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#ids ⇒ Object
:nodoc:.
-
#q ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(q) ⇒ Search
constructor
A new instance of Search.
- #results(o = {}) ⇒ Object
Methods inherited from Base
get_entries, get_token, parse, parse_json, user_info
Constructor Details
#initialize(q) ⇒ Search
Returns a new instance of Search.
9 10 11 12 |
# File 'lib/google/reader/search.rb', line 9 def initialize(q) self.q = q @executed = false end |
Instance Attribute Details
#ids ⇒ Object
:nodoc:
7 8 9 |
# File 'lib/google/reader/search.rb', line 7 def ids @ids end |
#q ⇒ Object
:nodoc:
7 8 9 |
# File 'lib/google/reader/search.rb', line 7 def q @q end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/google/reader/search.rb', line 14 def execute response = self.class.get(SEARCH_IDS_URL, :query_hash => { :num => 1000, :output => 'json', :q => q }) self.ids = self.class.parse_json(response)['results'].collect { |r| r['id'] } @executed = true end |
#results(o = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/google/reader/search.rb', line 24 def results(o={}) = { :token => nil, :start => 0, :num => 20, }.merge(o) [:token] ||= self.class.get_token if ids.size > 0 i_str = ids[[:start]] + '&' i_str += ids[([:start]+1)..[:num]].collect { |id| ["i=#{id}&"] unless id.nil? }.join('') self.class.post(SEARCH_CONTENTS_URL, :form_data => { :T => [:token], :i => i_str, }) end end |