Class: TwitterImages::Requester
- Inherits:
-
Object
- Object
- TwitterImages::Requester
- Defined in:
- lib/twitter_images/requester.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#all_links ⇒ Object
Returns the value of attribute all_links.
-
#downloader ⇒ Object
readonly
Returns the value of attribute downloader.
-
#https ⇒ Object
Returns the value of attribute https.
-
#max_id ⇒ Object
Returns the value of attribute max_id.
-
#response ⇒ Object
Returns the value of attribute response.
-
#search ⇒ Object
readonly
Returns the value of attribute search.
Instance Method Summary collapse
- #get_links(search, amount) ⇒ Object
-
#initialize(downloader) ⇒ Requester
constructor
A new instance of Requester.
- #start(search, amount) ⇒ Object
Constructor Details
#initialize(downloader) ⇒ Requester
Returns a new instance of Requester.
6 7 8 9 |
# File 'lib/twitter_images/requester.rb', line 6 def initialize(downloader) @downloader = downloader @all_links = [] end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
4 5 6 |
# File 'lib/twitter_images/requester.rb', line 4 def address @address end |
#all_links ⇒ Object
Returns the value of attribute all_links.
4 5 6 |
# File 'lib/twitter_images/requester.rb', line 4 def all_links @all_links end |
#downloader ⇒ Object (readonly)
Returns the value of attribute downloader.
3 4 5 |
# File 'lib/twitter_images/requester.rb', line 3 def downloader @downloader end |
#https ⇒ Object
Returns the value of attribute https.
4 5 6 |
# File 'lib/twitter_images/requester.rb', line 4 def https @https end |
#max_id ⇒ Object
Returns the value of attribute max_id.
4 5 6 |
# File 'lib/twitter_images/requester.rb', line 4 def max_id @max_id end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/twitter_images/requester.rb', line 4 def response @response end |
#search ⇒ Object (readonly)
Returns the value of attribute search.
3 4 5 |
# File 'lib/twitter_images/requester.rb', line 3 def search @search end |
Instance Method Details
#get_links(search, amount) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/twitter_images/requester.rb', line 17 def get_links(search, amount) loop do setup_address(search) setup_https issue_request parse_response break if all_links.count > amount end trim_links(amount) end |
#start(search, amount) ⇒ Object
11 12 13 14 15 |
# File 'lib/twitter_images/requester.rb', line 11 def start(search, amount) check_env get_links(search, amount) download end |