Class: Present::Page
- Inherits:
-
Object
- Object
- Present::Page
- Defined in:
- lib/present/page.rb
Instance Method Summary collapse
-
#initialize(stanza, screen) ⇒ Page
constructor
A new instance of Page.
- #start ⇒ Object
Constructor Details
#initialize(stanza, screen) ⇒ Page
Returns a new instance of Page.
3 4 5 6 |
# File 'lib/present/page.rb', line 3 def initialize(stanza, screen) @lines = stanza.split("\n") @screen = screen end |
Instance Method Details
#start ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/present/page.rb', line 8 def start @screen.clear stack = [['cap', '']] execute_command = proc do command, text = stack.pop dispatch_command command, text @screen.refresh end @lines.each do |line| text, command = line.split(/\s+/, 2).reverse if command.nil? next elsif command.empty? stack.last[1] += "\n#{text}" else execute_command.call stack.push [command, text] end end execute_command.call end |