Class: PGCrypto::Key
- Inherits:
-
Object
- Object
- PGCrypto::Key
- Defined in:
- lib/pgcrypto/key.rb
Instance Attribute Summary collapse
-
#armored ⇒ Object
writeonly
Sets the attribute armored.
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#path ⇒ Object
Returns the value of attribute path.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #armored? ⇒ Boolean
- #dearmored ⇒ Object
- #encrypt(value) ⇒ Object
-
#initialize(options = {}) ⇒ Key
constructor
A new instance of Key.
- #password? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Key
Returns a new instance of Key.
29 30 31 32 33 34 35 36 37 |
# File 'lib/pgcrypto/key.rb', line 29 def initialize( = {}) if .is_a?(String) self.value = elsif .is_a?(Hash) .each do |key, value| send("#{key}=", value) end end end |
Instance Attribute Details
#armored=(value) ⇒ Object (writeonly)
Sets the attribute armored
15 16 17 |
# File 'lib/pgcrypto/key.rb', line 15 def armored=(value) @armored = value end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/pgcrypto/key.rb', line 13 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
13 14 15 |
# File 'lib/pgcrypto/key.rb', line 13 def password @password end |
#path ⇒ Object
Returns the value of attribute path.
14 15 16 |
# File 'lib/pgcrypto/key.rb', line 14 def path @path end |
#value ⇒ Object
Returns the value of attribute value.
13 14 15 |
# File 'lib/pgcrypto/key.rb', line 13 def value @value end |
Instance Method Details
#armored? ⇒ Boolean
17 18 19 |
# File 'lib/pgcrypto/key.rb', line 17 def armored? @armored end |
#dearmored ⇒ Object
21 22 23 |
# File 'lib/pgcrypto/key.rb', line 21 def dearmored "#{'dearmor(' if armored?}'#{self}'#{')' if armored?}" end |
#encrypt(value) ⇒ Object
25 26 27 |
# File 'lib/pgcrypto/key.rb', line 25 def encrypt(value) %[pgp_pub_encrypt('#{value}', #{dearmored})] end |
#password? ⇒ Boolean
39 40 41 |
# File 'lib/pgcrypto/key.rb', line 39 def password? ", '#{password}'" if password end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/pgcrypto/key.rb', line 50 def to_s value end |