Class: Looks::Command::Images

Inherits:
AccountManagement show all
Defined in:
lib/looks/command/images.rb

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#run, #to_s, #usage

Constructor Details

#initialize(config) ⇒ Images

Returns a new instance of Images.



8
9
10
11
12
# File 'lib/looks/command/images.rb', line 8

def initialize(config)
  super

  @verbose = false
end

Instance Method Details

#configure(opts) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/looks/command/images.rb', line 14

def configure(opts)
  super

  opts.separator ""
  opts.separator "Options:"

  opts.on('-v', '--verbose', "Be verbose") do |address|
    @verbose = true
  end
end

#execute(args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/looks/command/images.rb', line 25

def execute(args)
  super

   = Gravatar::Account.new(config)
  images  = .images

  if @verbose
    addresses = .addresses

    images.each do |image|
      puts "#{image.id}"
      addresses.select { |a| a.image == image }.each do |address|
        puts "  #{address}"
      end
    end
  else
    puts images
  end
end