Class: TwitterImages::Requester

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_images/requester.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#addressObject

Returns the value of attribute address.



4
5
6
# File 'lib/twitter_images/requester.rb', line 4

def address
  @address
end

Returns the value of attribute all_links.



4
5
6
# File 'lib/twitter_images/requester.rb', line 4

def all_links
  @all_links
end

#downloaderObject (readonly)

Returns the value of attribute downloader.



3
4
5
# File 'lib/twitter_images/requester.rb', line 3

def downloader
  @downloader
end

#httpsObject

Returns the value of attribute https.



4
5
6
# File 'lib/twitter_images/requester.rb', line 4

def https
  @https
end

#max_idObject

Returns the value of attribute max_id.



4
5
6
# File 'lib/twitter_images/requester.rb', line 4

def max_id
  @max_id
end

#responseObject

Returns the value of attribute response.



4
5
6
# File 'lib/twitter_images/requester.rb', line 4

def response
  @response
end

#searchObject (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



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