Class: TP::Presenter
- Inherits:
-
Object
- Object
- TP::Presenter
- Defined in:
- lib/tp/presenter.rb
Instance Attribute Summary collapse
-
#markdown ⇒ Object
readonly
Returns the value of attribute markdown.
Instance Method Summary collapse
- #clear_screen ⇒ Object
-
#initialize(markdown) ⇒ Presenter
constructor
A new instance of Presenter.
- #present ⇒ Object
- #render_slides ⇒ Object
- #slide_deck ⇒ Object
- #slides ⇒ Object
- #suggest_sizing ⇒ Object
Constructor Details
#initialize(markdown) ⇒ Presenter
Returns a new instance of Presenter.
5 6 7 |
# File 'lib/tp/presenter.rb', line 5 def initialize(markdown) @markdown = markdown end |
Instance Attribute Details
#markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
3 4 5 |
# File 'lib/tp/presenter.rb', line 3 def markdown @markdown end |
Instance Method Details
#clear_screen ⇒ Object
37 38 39 |
# File 'lib/tp/presenter.rb', line 37 def clear_screen Screen.clear! end |
#present ⇒ Object
9 10 11 12 13 |
# File 'lib/tp/presenter.rb', line 9 def present suggest_sizing clear_screen end |
#render_slides ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tp/presenter.rb', line 20 def loop do Renderer.new(.current_frame).render case Keyboard.read when :right, :down, :space, :return, 'l', 'j', 'd', 's' .next when :left, :up, :backspace, 'h', 'k', 'a', 'w' .previous when 'q' break end break if .ended? end end |
#slide_deck ⇒ Object
49 50 51 |
# File 'lib/tp/presenter.rb', line 49 def @slide_deck ||= SlideDeck.new end |
#slides ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/tp/presenter.rb', line 41 def result = markdown.split /^#/ result.reject! &:empty? result.map! { |string| "##{string}" } result.map { |string| SlideFactory.from_markdown string } end |
#suggest_sizing ⇒ Object
15 16 17 18 |
# File 'lib/tp/presenter.rb', line 15 def suggest_sizing Screen.suggest .width, .height Keyboard.wait_for_return end |