Class: Rorr::DontAskMe
- Inherits:
-
Object
- Object
- Rorr::DontAskMe
- Defined in:
- lib/rorr/dont_ask_me.rb
Instance Method Summary collapse
-
#initialize ⇒ DontAskMe
constructor
A new instance of DontAskMe.
- #start ⇒ Object
Constructor Details
#initialize ⇒ DontAskMe
Returns a new instance of DontAskMe.
3 4 5 6 7 |
# File 'lib/rorr/dont_ask_me.rb', line 3 def initialize @dir = %w(ruby rails) @questions = [] create_questions end |
Instance Method Details
#start ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rorr/dont_ask_me.rb', line 9 def start system 'clear' UI.puts "\nWelcome to #{"\"Don't ask me Ruby or Rails\"".light_cyan}" UI.puts "Let's check whether you remember where Ruby ends and Rails\n" Score.start @questions.each.with_index(1) do |question, index| UI.question(question[:qu], index) Score.init(index) UI.puts "ruby or rails? (Type the #{'ruby'.green} or #{'rails'.green} to answer, #{UI.skip}, #{UI.exit})\n\n" while answer = UI.gets case answer.downcase when question[:ans] UI.puts "Yes, this is #{question[:ans]}!".green Score.add_correct break when 'ruby', 'rails' UI.puts "No, this is not #{answer}!".red Score.add_wrong break when 'skip' UI.puts 'Skip the Question!'.light_blue Score.add_skip break when 'exit' then exit when '' then UI.puts_with_delay 'Please enter again!'.light_blue else UI.puts_with_delay 'Error, Please enter again!'.light_red Score.add_retry end end Score.add_report UI.solution(question[:sol]) end Score.finish UI.report end |