Class: Looks::Command::Set

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

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from AccountManagement

#configure

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/set.rb', line 9

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

#execute(args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/looks/command/set.rb', line 13

def execute(args)
  super

  address, id = args

   = Gravatar::Account.new(config)

  begin
    .set(address, id)
  rescue Gravatar::IncorrectMethodParameterError
    addresses = .addresses.map { |address| address.email }

    if addresses.include? address
      raise Error, "#{id}: Unknown identifier"
    else
      raise Error, "#{address}: Unknown email address"
    end
  end
end