Class: Thor::Shell::Basic
- Inherits:
-
Object
- Object
- Thor::Shell::Basic
- Defined in:
- lib/thorium/core/bootstrap.rb
Overview
Top level commit
Instance Method Summary collapse
- #ask_filtered(statement, color, options) ⇒ Object
- #correct_answer(answer_set, options, color, statement) ⇒ Object
Instance Method Details
#ask_filtered(statement, color, options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/thorium/core/bootstrap.rb', line 7 def ask_filtered(statement, color, ) answer_set = [:limited_to] if .key? :skip statement += if [:skip].strip.empty? ' (Enter to skip)' else " (#{[:skip]} to skip)" end end correct_answer answer_set, , color, statement end |
#correct_answer(answer_set, options, color, statement) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/thorium/core/bootstrap.rb', line 19 def correct_answer(answer_set, , color, statement) result = nil answers = answer_set.join(', ') statement += " [#{answers}]" unless [:mute_limit_set] until result answer = ask_simply(statement, color, ) skipped = (.key?(:skip) && (answer == [:skip].chomp)) result = answer_set.include?(answer) || skipped ? answer : nil unless result if [:mute_limit_set] say('Your response is invalid. Please try again.') else say("Your response must be one of: [#{answers}]. Please try again.") end end end result end |