Class: MotherDucker::StrategyCoordinator
- Inherits:
-
Object
- Object
- MotherDucker::StrategyCoordinator
- Defined in:
- lib/mother_ducker/strategy_orchestrator.rb
Instance Method Summary collapse
- #animation_with_a_great_final_frame ⇒ Object
- #debug ⇒ Object
-
#initialize ⇒ StrategyCoordinator
constructor
A new instance of StrategyCoordinator.
- #meditate ⇒ Object
- #parse_error(message) ⇒ Object
- #sleep_with_dots(seconds) ⇒ Object
- #strategize ⇒ Object
Constructor Details
#initialize ⇒ StrategyCoordinator
Returns a new instance of StrategyCoordinator.
6 7 8 9 |
# File 'lib/mother_ducker/strategy_orchestrator.rb', line 6 def initialize @meditation_used = false @debugging_used = false end |
Instance Method Details
#animation_with_a_great_final_frame ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/mother_ducker/strategy_orchestrator.rb', line 83 def animation_with_a_great_final_frame db_path = File.join(__dir__, 'ascii_animations/ascii_meditation') arr = (0..90).to_a arr.delete_at(0) arr.delete_at(0) arr.delete_at(6) arr.delete_at(9) arr.delete_at(24) arr.delete_at(49) arr.delete_at(72) arr.delete_at(83) arr.delete_at(82) 2.times do for i in arr puts "\033[2J" File.foreach("#{db_path}/#{i}.txt") do |f| puts f end sleep(0.1) i += 1 end end end |
#debug ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mother_ducker/strategy_orchestrator.rb', line 39 def debug puts "What about some debugging?" puts "copy and paste the error which you are seeing, I will help you understand it:" error = gets.chomp parse_error(error) puts "good ! You're doing better. I'm glad" @debugging_used = true end |
#meditate ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mother_ducker/strategy_orchestrator.rb', line 21 def meditate emoji_array = ["🌬", "😤", "🌈"] text_array = MotherDucker::MEDITATION_TEXT puts "I think some meditation would be useful. Let me guide you through it" text_array.each do |sentence| sleep_with_dots(3) puts sentence %x(say "#{sentence}") end animation_with_a_great_final_frame puts "Thanks. I hope that helped you relax" @meditation_used = true end |
#parse_error(message) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mother_ducker/strategy_orchestrator.rb', line 50 def parse_error() if .match(/undefined method/) line = /\:\d+\:/.match()[0].gsub(":", "") file_name = /\#\<\w+\:/.match()[0].gsub("#<", "").gsub(":", "") puts "\n" puts "Looks like we have an undefined method on line #{line} of your #{file_name.downcase}.rb file.\n Do you know what this means?" answer_1 = gets.chomp if answer_1 == "yes" puts "Then go to line #{line} and fix it..." else puts "You haven't properly defined a method in your #{file_name} class." puts "Let's go to line #{line} of your code, and see what's wrong." puts "Which method is being called on line #{line}?" method_name = gets.chomp puts "Is there a method defined \"#{method_name}\" in your #{file_name} class?" answer_2 = gets.chomp if answer_2 == "no" puts "Create a method named \"#{method_name}\" in your #{file_name} class." end end end end |
#sleep_with_dots(seconds) ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/mother_ducker/strategy_orchestrator.rb', line 73 def sleep_with_dots(seconds) i = 0 while i < seconds sleep(0.5) print "." i += 0.5 end puts "" end |
#strategize ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/mother_ducker/strategy_orchestrator.rb', line 11 def strategize if !(@meditation_used) meditate elsif !(@debugging_used) debug else puts "we did all we could ! maybe take a nap ? or look at memes?" end end |