Class: TTY2::Prompt::Question::Checks::CheckConversion

Inherits:
Object
  • Object
show all
Defined in:
lib/tty2/prompt/question/checks.rb

Class Method Summary collapse

Class Method Details

.call(question, value) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/tty2/prompt/question/checks.rb', line 88

def self.call(question, value)
  if question.convert? && !Utils.blank?(value)
    result = question.convert_result(value)
    if result == Const::Undefined
      tokens = { value: value, type: question.convert }
      [value, question.message_for(:convert?, tokens)]
    else
      [result]
    end
  else
    [value]
  end
end