Class: Looks::Command::Pull

Inherits:
Base
  • Object
show all
Defined in:
lib/looks/command/pull.rb

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#initialize, #run, #to_s, #usage

Constructor Details

This class inherits a constructor from Looks::Command::Base

Instance Method Details

#argumentsObject



9
10
11
# File 'lib/looks/command/pull.rb', line 9

def arguments
  [ '<address>', '<filename>' ]
end

#execute(args) ⇒ Object



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

def execute(args)
  super

  address, filename = args

  begin
    File.open(filename, 'wb') do |file|
      file.write(Gravatar.get(address))
    end
  rescue IOError, SystemCallError
    raise Error, "#{filename}: Cannot write file"
  end
end