Class: Teletype::Practice
- Inherits:
-
Object
- Object
- Teletype::Practice
- Defined in:
- lib/teletype/practice.rb
Overview
Initializes screen size and click stats, then start the practice page by page.
Instance Method Summary collapse
-
#initialize(text, height: 5, width: 120) ⇒ Practice
constructor
A new instance of Practice.
- #start ⇒ Object
Constructor Details
#initialize(text, height: 5, width: 120) ⇒ Practice
Returns a new instance of Practice.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/teletype/practice.rb', line 6 def initialize(text, height: 5, width: 120) @screen = Screen.new(height: height, width: width) @stats = Stats.new @lines = [] text.each_line do |line| line.chars.each_slice(@screen.width) do |slice| @lines << slice.join end end @pager = Pager.new(@lines, @stats, @screen.height) end |
Instance Method Details
#start ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/teletype/practice.rb', line 20 def start at_exit { @stats.save } @pager.each do |lines| Page.new(lines, @screen, @stats).run end end |