Sha256: a540eb1906054e14ab2a14a8b34abf1768916e030d7ed1618b221f4c3812309a
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require 'eac_ruby_utils/core_ext' module EacCli module RunnerWith module Confirmation class InputResult INPUT_NO_FOR_ONE = 'n' INPUT_NO_FOR_ALL = 'N' INPUT_YES_FOR_ONE = 'y' INPUT_YES_FOR_ALL = 'Y' INPUT_FOR_ONE = [INPUT_NO_FOR_ONE, INPUT_YES_FOR_ONE].freeze INPUT_FOR_ALL = [INPUT_NO_FOR_ALL, INPUT_YES_FOR_ALL].freeze INPUT_NO = [INPUT_NO_FOR_ONE, INPUT_NO_FOR_ALL].freeze INPUT_YES = [INPUT_YES_FOR_ONE, INPUT_YES_FOR_ALL].freeze INPUT_LIST = [INPUT_NO_FOR_ALL, INPUT_NO_FOR_ONE, INPUT_YES_FOR_ONE, INPUT_YES_FOR_ALL] .freeze class << self enable_speaker # @param message [String] # @return [EacCli::RunnerWith::Confirmation::InputResult] def by_message(message) new(input(message, list: INPUT_LIST)) end end common_constructor :input_value # @return [Boolean] def confirm? input_value_to_bool(INPUT_NO, INPUT_YES) end # @return [Boolean] def for_all? input_value_to_bool(INPUT_FOR_ONE, INPUT_FOR_ALL) end private # @param false_list [Array<String>] # @param true_list [Array<String>] # @return [Boolean] def input_value_to_bool(false_list, true_list) return false if false_list.include?(input_value) return true if true_list.include?(input_value) ibr input_value end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eac_cli-0.40.1 | lib/eac_cli/runner_with/confirmation/input_result.rb |
eac_cli-0.40.0 | lib/eac_cli/runner_with/confirmation/input_result.rb |