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.
19 20 21 22 23 24 25 26 27 |
# File 'lib/pgcrypto/key.rb', line 19 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
5 6 7 |
# File 'lib/pgcrypto/key.rb', line 5 def armored=(value) @armored = value end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/pgcrypto/key.rb', line 3 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/pgcrypto/key.rb', line 3 def password @password end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/pgcrypto/key.rb', line 4 def path @path end |
#value ⇒ Object
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
7 8 9 |
# File 'lib/pgcrypto/key.rb', line 7 def armored? @armored end |
#dearmored ⇒ Object
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
29 30 31 |
# File 'lib/pgcrypto/key.rb', line 29 def password? ", '#{password}'" if password end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/pgcrypto/key.rb', line 40 def to_s value end |