Class: Gingerice::Command
- Inherits:
-
Object
- Object
- Gingerice::Command
- Defined in:
- lib/gingerice/command.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#args_parser ⇒ Object
readonly
Returns the value of attribute args_parser.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(args) ⇒ Command
constructor
A new instance of Command.
Constructor Details
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
8 9 10 |
# File 'lib/gingerice/command.rb', line 8 def args @args end |
#args_parser ⇒ Object (readonly)
Returns the value of attribute args_parser.
8 9 10 |
# File 'lib/gingerice/command.rb', line 8 def args_parser @args_parser end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/gingerice/command.rb', line 8 def @options end |
Instance Method Details
#execute ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gingerice/command.rb', line 18 def execute if .has_key?(:show) case [:show] when :help puts args_parser when :version puts "Gingerice: #{Gingerice::VERSION}" end else parser_opts = .select { |k, _| Parser..keys.include?(k) } parser = Parser.new(parser_opts) response = parser.parse(args.last) if [:output] === :verbose ap response else puts response end end end |