Class: Aviary::Search
- Inherits:
-
Object
- Object
- Aviary::Search
- Defined in:
- lib/aviary/search.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#twitter ⇒ Object
readonly
Returns the value of attribute twitter.
Instance Method Summary collapse
-
#initialize(config) ⇒ Search
constructor
A new instance of Search.
- #next_page! ⇒ Object
-
#next_page? ⇒ Boolean
True if there is another page to fetch from Twitter and we haven’t exceeded the limit.
- #process ⇒ Object
Constructor Details
#initialize(config) ⇒ Search
Returns a new instance of Search.
5 6 7 8 9 |
# File 'lib/aviary/search.rb', line 5 def initialize(config) @twitter = Twitter::Search.new.filter('links').no_retweets.per_page(100).containing(config[:query]) @limit = config[:limit] || 50 @current_page = 1 end |
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
3 4 5 |
# File 'lib/aviary/search.rb', line 3 def current_page @current_page end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
3 4 5 |
# File 'lib/aviary/search.rb', line 3 def limit @limit end |
#twitter ⇒ Object (readonly)
Returns the value of attribute twitter.
3 4 5 |
# File 'lib/aviary/search.rb', line 3 def twitter @twitter end |
Instance Method Details
#next_page! ⇒ Object
30 31 32 |
# File 'lib/aviary/search.rb', line 30 def next_page! @current_page += 1 end |
#next_page? ⇒ Boolean
True if there is another page to fetch from Twitter and we haven’t exceeded the limit.
Returns boolean.
26 27 28 |
# File 'lib/aviary/search.rb', line 26 def next_page? self.twitter.next_page? && self.current_page < self.limit end |