Class: Cliqr::Parser::OptionToken Private

Inherits:
Token
  • Object
show all
Defined in:
lib/cliqr/parser/option_token.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.

Represents a option token

Direct Known Subclasses

BooleanOptionToken, SingleValuedOptionToken

Instance Attribute Summary collapse

Attributes inherited from Token

#arg

Instance Method Summary collapse

Methods inherited from Token

#active?

Constructor Details

#initialize(name, arg) ⇒ OptionToken

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.

Create a new option token with a name and value

Parameters:

  • name (String)

    Long name of the option

  • arg (String)

    Argument used to parse option name



23
24
25
26
27
28
# File 'lib/cliqr/parser/option_token.rb', line 23

def initialize(name, arg)
  super(arg)

  @name = name
  # @value = value
end

Instance Attribute Details

#nameString

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.

Name of the option token

Returns:

  • (String)


12
13
14
# File 'lib/cliqr/parser/option_token.rb', line 12

def name
  @name
end

#valueString

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.

Value of the option token

Returns:

  • (String)


17
18
19
# File 'lib/cliqr/parser/option_token.rb', line 17

def value
  @value
end

Instance Method Details

#buildHash

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.

Get the token representation

Returns:

  • (Hash)

    A hash of the option name and its value



33
34
35
36
37
38
# File 'lib/cliqr/parser/option_token.rb', line 33

def build
  {
      :name => @name.to_s,
      :value => @value
  }
end

#collect(input_builder) ⇒ Cliqr::Parser::ParsedInputBuilder

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.

Collect this token’s name and value into a input builder

arguments

Parameters:

Returns:



53
54
55
# File 'lib/cliqr/parser/option_token.rb', line 53

def collect(input_builder)
  input_builder.add_option_token(self) unless active?
end

#valid?Boolean

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.

A option token is not valid if it does not have a name

Returns:

  • (Boolean)

    false if the token’s name is nil



43
44
45
# File 'lib/cliqr/parser/option_token.rb', line 43

def valid?
  !@name.nil?
end