Class: Mpx::Request
- Inherits:
-
Object
- Object
- Mpx::Request
- Defined in:
- lib/mpx/request.rb
Overview
Extracts ‘<SUBCOMMAND/ALIAS>:<ARG> <ARGS>`.
Instance Method Summary collapse
- #args ⇒ Object
-
#initialize(args) ⇒ Request
constructor
A new instance of Request.
- #name ⇒ Object
Constructor Details
#initialize(args) ⇒ Request
Returns a new instance of Request.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mpx/request.rb', line 5 def initialize(args) directive, *rest = args if !directive&.include? ':' raise 'missing directive' end cmd, first_arg = directive.split ':', 2 if first_arg.empty? raise 'missing subcommand' end @name = cmd.empty? ? nil : cmd @args = [first_arg, *rest] end |
Instance Method Details
#args ⇒ Object
24 25 26 |
# File 'lib/mpx/request.rb', line 24 def args return @args end |
#name ⇒ Object
20 21 22 |
# File 'lib/mpx/request.rb', line 20 def name return @name end |