Class: Typingtutor::Runner

Inherits:
Object
  • Object
show all
Includes:
HighLine::SystemExtensions
Defined in:
lib/typingtutor/runner.rb

Instance Method Summary collapse

Instance Method Details

#run(exercise_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/typingtutor/runner.rb', line 5

def run(exercise_name)
  exercise = exercises[exercise_name]
  if exercise
    setup_color_scheme
    play_intro
    @start = Time.now
    stats = exercise.map { |line| Line.new(line).play }
    print_stats(stats)
  else
    puts "usage: typingtutor <exercise>"
    puts "available:"
    exercises.keys.each {|e| puts "- #{e}"}
  end
end