Class: UnixCrypt::CommandLine
- Inherits:
-
Object
- Object
- UnixCrypt::CommandLine
- Defined in:
- lib/unix_crypt/command_line.rb
Defined Under Namespace
Classes: Opts
Constant Summary collapse
- Abort =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #encrypt ⇒ Object
-
#initialize(argv) ⇒ CommandLine
constructor
A new instance of CommandLine.
Constructor Details
#initialize(argv) ⇒ CommandLine
Returns a new instance of CommandLine.
15 16 17 |
# File 'lib/unix_crypt/command_line.rb', line 15 def initialize(argv) @options = Opts.parse(argv) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/unix_crypt/command_line.rb', line 13 def @options end |
Instance Method Details
#encrypt ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/unix_crypt/command_line.rb', line 19 def encrypt if @options.password.nil? @options.password = ask_password else password_warning end begin puts @options.hasher.build(@options.password, @options.salt, @options.rounds) rescue UnixCrypt::Error => e $stderr.puts "password generation failed: #{e.}" end clear_string(@options.password) end |