Class: Mpx::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/mpx/request.rb

Overview

Extracts ‘<SUBCOMMAND/ALIAS>:<ARG> <ARGS>`.

Instance Method Summary collapse

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

#argsObject



24
25
26
# File 'lib/mpx/request.rb', line 24

def args
  return @args
end

#nameObject



20
21
22
# File 'lib/mpx/request.rb', line 20

def name
  return @name
end