Class: Cliqr::Command::CommandOption Private

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

A holder class for a command line argument’s name and value

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, values, option_config) ⇒ Cliqr::Command::CommandContext

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 command line option instance

Parameters:

  • name (String)

    Name of the option

  • values (Array)

    Parsed values for this option

  • option_config (Cliqr::Config::Option)

    Option’s config settings



263
264
265
266
# File 'lib/cliqr/command/command_context.rb', line 263

def initialize(name, values, option_config)
  @name = name
  @values = values.map { |value| run_value_operator(value, option_config.operator) }
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 a command line argument option

Returns:

  • (String)


249
250
251
# File 'lib/cliqr/command/command_context.rb', line 249

def name
  @name
end

#valuesArray

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 array for the command line argument’s option

Returns:

  • (Array)


254
255
256
# File 'lib/cliqr/command/command_context.rb', line 254

def values
  @values
end

Instance Method Details

#to_sString

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 string representation for this option

Returns:

  • (String)


279
280
281
# File 'lib/cliqr/command/command_context.rb', line 279

def to_s
  value.to_s
end

#valueObject

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 value for this option

Returns:

  • (Object)

    Joins in a CSV format if multiple



271
272
273
274
# File 'lib/cliqr/command/command_context.rb', line 271

def value
  return values.first if values.length == 1
  values.join(',')
end