Class: Cwflash::Runner
- Inherits:
-
Object
- Object
- Cwflash::Runner
- Defined in:
- lib/cwflash.rb
Instance Method Summary collapse
-
#initialize(filename = "01-eish.json") ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(filename = "01-eish.json") ⇒ Runner
Returns a new instance of Runner.
6 7 8 |
# File 'lib/cwflash.rb', line 6 def initialize(filename="01-eish.json") @path = File.absolute_path(File.join(File.dirname(__FILE__), "..", "samples", filename)) end |
Instance Method Details
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cwflash.rb', line 10 def run sender = Brasspounder::Sender.new(speed = :norm, freq = 600, verbose = false) cards = Querinator::Importer.new.parse(@path) cards.shuffle.each do |card| puts "\n Playing #{card.pose.upcase}\n\n" sender.send card.pose print "What was that code?\n-> " input = gets() input = input.chomp if card.is_correct?(input) puts "Hooray!!" else puts "oooooh." puts "The correct answer was '#{card.answer.upcase}'" end end end |