Class: Shhh::App::Args
- Inherits:
-
Object
- Object
- Shhh::App::Args
- Defined in:
- lib/shhh/app/args.rb
Constant Summary collapse
- OPTIONS_MODE_SELECTED =
%i(encrypt decrypt generate edit keychain)
- OPTIONS_REQUIRE_KEY =
%i(encrypt decrypt edit)
- OPTIONS_SPECIFY_KEY =
%i(private_key interactive keyfile keychain)
- OPTIONS_SPECIFY_OUTPUT =
%i(output quiet)
Instance Attribute Summary collapse
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#selected_options ⇒ Object
Returns the value of attribute selected_options.
Instance Method Summary collapse
- #do_options_require_key? ⇒ Boolean
- #do_options_specify_key? ⇒ Boolean
-
#do_options_specify_mode? ⇒ Boolean
TODO: generate these methods dynamically.
-
#initialize(opts) ⇒ Args
constructor
A new instance of Args.
- #output_class ⇒ Object
Constructor Details
#initialize(opts) ⇒ Args
Returns a new instance of Args.
13 14 15 16 |
# File 'lib/shhh/app/args.rb', line 13 def initialize(opts) self.opts = opts self. = opts.keys.reject { |k| !opts[k] } end |
Instance Attribute Details
#opts ⇒ Object
Returns the value of attribute opts.
11 12 13 |
# File 'lib/shhh/app/args.rb', line 11 def opts @opts end |
#selected_options ⇒ Object
Returns the value of attribute selected_options.
11 12 13 |
# File 'lib/shhh/app/args.rb', line 11 def @selected_options end |
Instance Method Details
#do_options_require_key? ⇒ Boolean
27 28 29 |
# File 'lib/shhh/app/args.rb', line 27 def do?(OPTIONS_REQUIRE_KEY) end |
#do_options_specify_key? ⇒ Boolean
23 24 25 |
# File 'lib/shhh/app/args.rb', line 23 def do?(OPTIONS_SPECIFY_KEY) end |
#do_options_specify_mode? ⇒ Boolean
TODO: generate these methods dynamically
19 20 21 |
# File 'lib/shhh/app/args.rb', line 19 def do?(OPTIONS_MODE_SELECTED) end |
#output_class ⇒ Object
31 32 33 34 |
# File 'lib/shhh/app/args.rb', line 31 def output_class output_type = OPTIONS_SPECIFY_OUTPUT.find { |o| opts[o] } # includes nil Shhh::App::Output.outputs[output_type] end |