Class: RubyGPG2::ParameterFileContents
- Inherits:
-
Object
- Object
- RubyGPG2::ParameterFileContents
- Defined in:
- lib/ruby_gpg2/parameter_file_contents.rb
Instance Attribute Summary collapse
-
#expiry ⇒ Object
readonly
Returns the value of attribute expiry.
-
#key_length ⇒ Object
readonly
Returns the value of attribute key_length.
-
#key_type ⇒ Object
readonly
Returns the value of attribute key_type.
-
#owner_comment ⇒ Object
readonly
Returns the value of attribute owner_comment.
-
#owner_email ⇒ Object
readonly
Returns the value of attribute owner_email.
-
#owner_name ⇒ Object
readonly
Returns the value of attribute owner_name.
-
#passphrase ⇒ Object
readonly
Returns the value of attribute passphrase.
-
#subkey_length ⇒ Object
readonly
Returns the value of attribute subkey_length.
-
#subkey_type ⇒ Object
readonly
Returns the value of attribute subkey_type.
Instance Method Summary collapse
- #expiry_date ⇒ Object
- #in_temp_file(tmpdir = nil) ⇒ Object
-
#initialize(opts) ⇒ ParameterFileContents
constructor
A new instance of ParameterFileContents.
- #to_s ⇒ Object
- #write_to(path) ⇒ Object
Constructor Details
#initialize(opts) ⇒ ParameterFileContents
Returns a new instance of ParameterFileContents.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 19 def initialize(opts) @key_type = resolve_key_type(opts) @key_length = resolve_key_length(opts, @key_type) @subkey_type = resolve_subkey_type(opts) @subkey_length = resolve_subkey_length(opts, @subkey_type) @owner_name = resolve_owner_name(opts) @owner_email = resolve_owner_email(opts) @owner_comment = resolve_owner_comment(opts) @expiry = resolve_expiry(opts) @passphrase = resolve_passphrase(opts) assert_required_parameters_present end |
Instance Attribute Details
#expiry ⇒ Object (readonly)
Returns the value of attribute expiry.
7 8 9 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 7 def expiry @expiry end |
#key_length ⇒ Object (readonly)
Returns the value of attribute key_length.
7 8 9 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 7 def key_length @key_length end |
#key_type ⇒ Object (readonly)
Returns the value of attribute key_type.
7 8 9 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 7 def key_type @key_type end |
#owner_comment ⇒ Object (readonly)
Returns the value of attribute owner_comment.
7 8 9 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 7 def owner_comment @owner_comment end |
#owner_email ⇒ Object (readonly)
Returns the value of attribute owner_email.
7 8 9 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 7 def owner_email @owner_email end |
#owner_name ⇒ Object (readonly)
Returns the value of attribute owner_name.
7 8 9 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 7 def owner_name @owner_name end |
#passphrase ⇒ Object (readonly)
Returns the value of attribute passphrase.
7 8 9 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 7 def passphrase @passphrase end |
#subkey_length ⇒ Object (readonly)
Returns the value of attribute subkey_length.
7 8 9 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 7 def subkey_length @subkey_length end |
#subkey_type ⇒ Object (readonly)
Returns the value of attribute subkey_type.
7 8 9 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 7 def subkey_type @subkey_type end |
Instance Method Details
#expiry_date ⇒ Object
33 34 35 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 33 def expiry_date expiry == :never ? 0 : expiry end |
#in_temp_file(tmpdir = nil) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 41 def in_temp_file(tmpdir = nil) Tempfile.create('parameter-file', tmpdir) do |f| f.write(to_s) f.flush yield f end end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 49 def to_s "#{to_parms.compact.join("\n")}\n" end |
#write_to(path) ⇒ Object
37 38 39 |
# File 'lib/ruby_gpg2/parameter_file_contents.rb', line 37 def write_to(path) File.open(path, 'w') { |f| f.write(to_s) } end |