Class: Clandestine::Commands::Get

Inherits:
Object
  • Object
show all
Defined in:
lib/clandestine/commands/get.rb

Instance Method Summary collapse

Constructor Details

#initialize(safe_password, key) ⇒ Get

Returns a new instance of Get.



11
12
13
14
# File 'lib/clandestine/commands/get.rb', line 11

def initialize(safe_password, key)
  @safe_password = safe_password
  @key = key.to_sym if key
end

Instance Method Details

#getObject



16
17
18
19
20
21
22
23
24
# File 'lib/clandestine/commands/get.rb', line 16

def get
  Safe.new(safe_password).open do |safe|
    if no_key_or_value?(safe)
      safe.contents
    else
      safe[key]
    end
  end
end