Class: Exekutor::Internal::CLI::DefaultOptionValue

Inherits:
Object
  • Object
show all
Defined in:
lib/exekutor/internal/cli/default_option_value.rb

Overview

Used as a default value for CLI flags.

Instance Method Summary collapse

Constructor Details

#initialize(description = nil, value: nil) ⇒ DefaultOptionValue

Returns a new instance of DefaultOptionValue.



10
11
12
13
# File 'lib/exekutor/internal/cli/default_option_value.rb', line 10

def initialize(description = nil, value: nil)
  @description = description || value&.to_s || "none"
  @value = value
end

Instance Method Details

#to_sObject

The value to display in the CLI help message



16
17
18
# File 'lib/exekutor/internal/cli/default_option_value.rb', line 16

def to_s
  @description
end

#valueObject

The actual value, if set. If the value responds to call, it will be called



21
22
23
24
25
26
27
# File 'lib/exekutor/internal/cli/default_option_value.rb', line 21

def value
  if @value.respond_to? :call
    @value.call
  else
    @value
  end
end