Class: PGCrypto::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/pgcrypto/key.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Key

Returns a new instance of Key.



19
20
21
22
23
24
25
26
27
# File 'lib/pgcrypto/key.rb', line 19

def initialize(options = {})
  if options.is_a?(String)
    self.value = options
  elsif options.is_a?(Hash)
    options.each do |key, value|
      send("#{key}=", value)
    end
  end
end

Instance Attribute Details

#armored=(value) ⇒ Object (writeonly)

Sets the attribute armored

Parameters:

  • value

    the value to set the attribute armored to.



5
6
7
# File 'lib/pgcrypto/key.rb', line 5

def armored=(value)
  @armored = value
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/pgcrypto/key.rb', line 3

def name
  @name
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/pgcrypto/key.rb', line 3

def password
  @password
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/pgcrypto/key.rb', line 4

def path
  @path
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/pgcrypto/key.rb', line 3

def value
  @value
end

Instance Method Details

#armored?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/pgcrypto/key.rb', line 7

def armored?
  @armored
end

#dearmoredObject



11
12
13
# File 'lib/pgcrypto/key.rb', line 11

def dearmored
  "#{'dearmor(' if armored?}'#{self}'#{')' if armored?}"
end

#encrypt(value) ⇒ Object



15
16
17
# File 'lib/pgcrypto/key.rb', line 15

def encrypt(value)
  %[pgp_pub_encrypt('#{value}', #{dearmored})]
end

#password?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/pgcrypto/key.rb', line 29

def password?
  ", '#{password}'" if password
end

#to_sObject



40
41
42
# File 'lib/pgcrypto/key.rb', line 40

def to_s
  value
end