Class: TTY::Prompt::Evaluator Private
- Inherits:
-
Object
- Object
- TTY::Prompt::Evaluator
- Defined in:
- lib/tty/prompt/evaluator.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.
Evaluates provided parameters and stops if any of them fails
Instance Attribute Summary collapse
- #results ⇒ Object readonly private
Instance Method Summary collapse
- #call(initial) ⇒ Object private
- #check(proc = nil, &block) ⇒ Object (also: #<<) private
-
#initialize(question, &block) ⇒ Evaluator
constructor
private
A new instance of Evaluator.
Constructor Details
#initialize(question, &block) ⇒ Evaluator
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.
Returns a new instance of Evaluator.
12 13 14 15 16 |
# File 'lib/tty/prompt/evaluator.rb', line 12 def initialize(question, &block) @question = question @results = [] instance_eval(&block) if block end |
Instance Attribute Details
#results ⇒ Object (readonly)
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.
10 11 12 |
# File 'lib/tty/prompt/evaluator.rb', line 10 def results @results end |
Instance Method Details
#call(initial) ⇒ Object
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.
18 19 20 21 |
# File 'lib/tty/prompt/evaluator.rb', line 18 def call(initial) seed = Result::Success.new(@question, initial) results.reduce(seed, &:with) end |
#check(proc = nil, &block) ⇒ Object Also known as: <<
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.
23 24 25 |
# File 'lib/tty/prompt/evaluator.rb', line 23 def check(proc = nil, &block) results << (proc || block) end |