Class: Duty::IO::CLI::Input
- Inherits:
-
Object
- Object
- Duty::IO::CLI::Input
- Defined in:
- lib/duty/io/cli.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
- #drop(index) ⇒ Object
-
#initialize(args) ⇒ Input
constructor
A new instance of Input.
- #join(seperator = '') ⇒ Object
- #needs_completion? ⇒ Boolean
- #needs_help? ⇒ Boolean
- #task_input ⇒ Object
- #task_name ⇒ Object
- #verbose? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Input
Returns a new instance of Input.
5 6 7 |
# File 'lib/duty/io/cli.rb', line 5 def initialize(args) @args = [args].flatten end |
Instance Method Details
#[](index) ⇒ Object
9 10 11 |
# File 'lib/duty/io/cli.rb', line 9 def[](index) args[index] end |
#drop(index) ⇒ Object
23 24 25 |
# File 'lib/duty/io/cli.rb', line 23 def drop(index) args.drop(1) end |
#join(seperator = '') ⇒ Object
27 28 29 |
# File 'lib/duty/io/cli.rb', line 27 def join(seperator='') args.join(seperator) end |
#needs_completion? ⇒ Boolean
35 36 37 |
# File 'lib/duty/io/cli.rb', line 35 def needs_completion? args.first == '--cmplt' end |
#needs_help? ⇒ Boolean
39 40 41 |
# File 'lib/duty/io/cli.rb', line 39 def needs_help? args.empty? || args == %w(-h) || args == %w(--help) end |
#task_input ⇒ Object
18 19 20 21 |
# File 'lib/duty/io/cli.rb', line 18 def task_input task, *rest = args rest end |
#task_name ⇒ Object
13 14 15 16 |
# File 'lib/duty/io/cli.rb', line 13 def task_name task, *rest = args task end |
#verbose? ⇒ Boolean
31 32 33 |
# File 'lib/duty/io/cli.rb', line 31 def verbose? args.include?('-v') || args.include?('--verbose') end |