Class: Evertils::Request
- Inherits:
-
Object
- Object
- Evertils::Request
- Defined in:
- lib/evertils/request.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Access command variable property externally.
-
#controller ⇒ Object
Access controller variable property externally.
-
#custom ⇒ Object
readonly
Access custom variable property externally.
-
#flags ⇒ Object
readonly
Access flags variable property externally.
-
#param ⇒ Object
Access param variable property externally.
-
#raw_flags ⇒ Object
readonly
Access raw_flags variable property externally.
Instance Method Summary collapse
-
#initialize ⇒ Request
constructor
Create the request object, parse ARGV for values.
Constructor Details
#initialize ⇒ Request
Create the request object, parse ARGV for values
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
#command ⇒ Object (readonly)
Access command variable property externally
6 7 8 |
# File 'lib/evertils/request.rb', line 6 def command @command end |
#controller ⇒ Object
Access controller variable property externally
4 5 6 |
# File 'lib/evertils/request.rb', line 4 def controller @controller end |
#custom ⇒ Object (readonly)
Access custom variable property externally
8 9 10 |
# File 'lib/evertils/request.rb', line 8 def custom @custom end |
#flags ⇒ Object (readonly)
Access flags variable property externally
10 11 12 |
# File 'lib/evertils/request.rb', line 10 def flags @flags end |
#param ⇒ Object
Access param variable property externally
14 15 16 |
# File 'lib/evertils/request.rb', line 14 def param @param end |
#raw_flags ⇒ Object (readonly)
Access raw_flags variable property externally
12 13 14 |
# File 'lib/evertils/request.rb', line 12 def raw_flags @raw_flags end |