Class: Aspera::Cli::CommandLine::Argument

Inherits:
Object
  • Object
show all
Defined in:
lib/aspera/cli/command_line.rb

Overview

Positional (non-option) command line token.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Argument

Returns a new instance of Argument.



32
33
34
35
36
# File 'lib/aspera/cli/command_line.rb', line 32

def initialize(value)
  @value = value
  @owner = nil
  @consumed = false
end

Instance Attribute Details

#consumed ⇒ Boolean

Returns true once used, as positional argument or as option value.

Returns:

  • (Boolean) —

    true once used, as positional argument or as option value



30
31
32
# File 'lib/aspera/cli/command_line.rb', line 30

def consumed
  @consumed
end

#owner ⇒ Option?

Returns option token claiming this token as its value (--opt value form).

Returns:

  • (Option, nil) —

    option token claiming this token as its value (--opt value form)



28
29
30
# File 'lib/aspera/cli/command_line.rb', line 28

def owner
  @owner
end

#value ⇒ String (readonly)

Returns the raw argument value.

Returns:

  • (String) —

    the raw argument value



26
27
28
# File 'lib/aspera/cli/command_line.rb', line 26

def value
  @value
end

Instance Method Details

#positional? ⇒ Boolean

Returns true if available as positional argument.

Returns:

  • (Boolean) —

    true if available as positional argument



39
# File 'lib/aspera/cli/command_line.rb', line 39

def positional? = !@consumed && @owner.nil?

#to_s ⇒ String

Returns raw argument value.

Returns:

  • (String) —

    raw argument value



42
# File 'lib/aspera/cli/command_line.rb', line 42

def to_s = @value