class TTY::Prompt::Choice

@api public
A single choice option

def self.from(val)

Other tags:
    Api: - public

Returns:
  • (Choice) -

Raises:
  • (ArgumentError) -

Parameters:
  • val (Object) --
def self.from(val)
  case val
  when Choice
    val
  when String, Symbol
    new(val, val)
  when Array
    new("#{val.first}", val.last)
  when Hash
    new("#{val.keys.first}", val.values.first)
  else
    raise ArgumentError, "#{val} cannot be coerced into Choice"
  end
end

def ==(other)

Other tags:
    Api: - public

Returns:
  • (Boolean) -
def ==(other)
  return false unless other.is_a?(self.class)
  name == other.name && value == other.value
end

def initialize(name, value)

Other tags:
    Api: - public
def initialize(name, value)
  @name  = name
  @value = value
end

def to_s

Other tags:
    Api: - public

Returns:
  • (String) -
def to_s
  "#{name}"
end

def value

Other tags:
    Api: - public
def value
  case @value
  when Proc
    @value.call
  else
    @value
  end
end