Class: ScrnShots

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/scrnshots.rb

Defined Under Namespace

Modules: CLI

Instance Method Summary collapse

Constructor Details

#initialize(username) ⇒ ScrnShots

Returns a new instance of ScrnShots.



9
10
11
# File 'lib/scrnshots.rb', line 9

def initialize(username)
  @username = username
end

Instance Method Details

#allObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/scrnshots.rb', line 13

def all
  page = 1

  while paths = screenshots_for_page(page)
    paths.each do |path|
      yield path
    end
    page += 1
  end
end

#screenshots_for_page(page) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/scrnshots.rb', line 24

def screenshots_for_page(page)
  results = self.class.get("/users/#{@username}/screenshots.json?page=#{page}")
  if results.size > 0
    results.collect do |result|
      result["images"]["fullsize"]
    end
  else
    false
  end
end