Sha256: 6f1353da2fc4fdddd0dee460597a1198007ae705030fd61360b488f09cc217ee
Contents?: true
Size: 660 Bytes
Versions: 5
Compression:
Stored size: 660 Bytes
Contents
# encoding: utf-8 # frozen_string_literal: true require_relative 'result' module TTY class Prompt # Evaluates provided parameters and stops if any of them fails # @api private class Evaluator attr_reader :results def initialize(question, &block) @question = question @results = [] instance_eval(&block) if block end def call(initial) seed = Result::Success.new(@question, initial) results.reduce(seed, &:with) end def check(proc = nil, &block) results << (proc || block) end alias_method :<<, :check end # Evaluator end # Prompt end # TTY
Version data entries
5 entries across 5 versions & 1 rubygems