Class: Cri::Command::ParserPartitioningDelegate Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cri/command.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Delegate used for partitioning the list of arguments and options. This delegate will stop the parser as soon as the first argument, i.e. the command, is found.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_argumentString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the last parsed argument, which, in this case, will be the first argument, which will be either nil or the command name.

Returns:

  • (String)

    The last parsed argument.



17
18
19
# File 'lib/cri/command.rb', line 17

def last_argument
  @last_argument
end

Instance Method Details

#argument_added(argument, parser) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Called when an argument is parsed.

Parameters:

  • argument (String)

    The argument

  • parser (Cri::Parser)

    The option parser



37
38
39
40
# File 'lib/cri/command.rb', line 37

def argument_added(argument, parser)
  @last_argument = argument
  parser.stop
end

#option_added(_key, _value, _parser) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Called when an option is parsed.

Parameters:

  • _key (Symbol)

    The option key (derived from the long format)

  • _value

    The option value

  • _parser (Cri::Parser)

    The option parser



28
# File 'lib/cri/command.rb', line 28

def option_added(_key, _value, _parser); end