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

#initializeRequester

Returns a new instance of Requester.



6
7
8
9
10
11
12
# File 'lib/twitter_images/requester.rb', line 6

def initialize
  @downloader = Downloader.new
  @authorizer = Authorizer.new
  @max_id = nil
  @tweets = []
  @links = []
end

Instance Attribute Details

#authorizerObject (readonly)

Returns the value of attribute authorizer.



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

def authorizer
  @authorizer
end

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#downloaderObject (readonly)

Returns the value of attribute downloader.



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

def downloader
  @downloader
end

Returns the value of attribute links.



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

def links
  @links
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

#searchObject (readonly)

Returns the value of attribute search.



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

def search
  @search
end

#tweetsObject

Returns the value of attribute tweets.



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

def tweets
  @tweets
end

Instance Method Details

#send_requests(search, amount) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/twitter_images/requester.rb', line 20

def send_requests(search, amount)
  configure_client
  loop do
    get_tweets(search, amount)
    break if @links.count > amount
  end
  trim_links(amount)
end

#start(search, amount) ⇒ Object



14
15
16
17
18
# File 'lib/twitter_images/requester.rb', line 14

def start(search, amount)
  puts "Getting links to the pictures..."
  send_requests(search, amount)
  download(links)
end