Class: Evertils::Request

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRequest

Create the request object, parse ARGV for values

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/evertils/request.rb', line 17

def initialize
  raise ArgumentError, "ARGV is empty" if ARGV.empty?

  @flags = ARGV.select { |f| f.start_with?('-') }.map { |f| f.split('=').map(&:to_sym) } || []
  @raw_flags = ARGV.select { |f| f.start_with?('-') } || []
  @controller = ARGV[0].to_sym unless ARGV[0].start_with?('-')
  @command = ARGV[1].to_sym unless ARGV[1].nil?

  return unless ARGV.size > 2

  @custom = ARGV[2..ARGV.size].reject { |p| p.start_with?('-') }.map(&:to_sym) || []
  @param = ARGV[2]
end

Instance Attribute Details

#commandObject (readonly)

Access command variable property externally



6
7
8
# File 'lib/evertils/request.rb', line 6

def command
  @command
end

#controllerObject

Access controller variable property externally



4
5
6
# File 'lib/evertils/request.rb', line 4

def controller
  @controller
end

#customObject (readonly)

Access custom variable property externally



8
9
10
# File 'lib/evertils/request.rb', line 8

def custom
  @custom
end

#flagsObject (readonly)

Access flags variable property externally



10
11
12
# File 'lib/evertils/request.rb', line 10

def flags
  @flags
end

#paramObject

Access param variable property externally



14
15
16
# File 'lib/evertils/request.rb', line 14

def param
  @param
end

#raw_flagsObject (readonly)

Access raw_flags variable property externally



12
13
14
# File 'lib/evertils/request.rb', line 12

def raw_flags
  @raw_flags
end