Class: FlexArgs::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/flex_args/parser.rb

Constant Summary collapse

ESCAPED_COMMA =
"a4ey8NGnXIVhsV"
DIGITS =
%r{\A [-+]? \d+ \z}x
MANY_FLAGS =
%r{\A - (.*) \z}x
RANGE =
%r{\A [-+]? \d+ \.\. [-+]? \d+ \z}x
SINGLE_FLAG =
%r{\A -- (.*) \z}x
VALUE =
%r{\A ([[:alpha:]][[:alnum:]_]*) : (.*) \z}x

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



7
8
9
# File 'lib/flex_args/parser.rb', line 7

def args
  @args
end

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/flex_args/parser.rb', line 7

def errors
  @errors
end

#flagsObject (readonly)

Returns the value of attribute flags.



7
8
9
# File 'lib/flex_args/parser.rb', line 7

def flags
  @flags
end

#flex_argsObject (readonly)

Returns the value of attribute flex_args.



7
8
9
# File 'lib/flex_args/parser.rb', line 7

def flex_args
  @flex_args
end

#positionalsObject (readonly)

Returns the value of attribute positionals.



7
8
9
# File 'lib/flex_args/parser.rb', line 7

def positionals
  @positionals
end

#values_from_argsObject (readonly)

Returns the value of attribute values_from_args.



7
8
9
# File 'lib/flex_args/parser.rb', line 7

def values_from_args
  @values_from_args
end

Instance Method Details

#parse(args) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/flex_args/parser.rb', line 16

def parse(args)
  init_values
  args.each { parse_arg it }
  return [:ok, result] if errors.empty?

  [:error, errors]
end