Class: Slideck::Renderer Private
- Inherits:
-
Object
- Object
- Slideck::Renderer
- Defined in:
- lib/slideck/renderer.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Responsible for rendering slides
Instance Attribute Summary collapse
-
#cursor ⇒ TTY::Cursor
readonly
The terminal cursor.
Instance Method Summary collapse
-
#clear ⇒ String
Clear terminal screen.
-
#initialize(converter, ansi, cursor, width: nil, height: nil) ⇒ Renderer
constructor
Create a Renderer instance.
-
#render(metadata, slide, current_num, num_of_slides) ⇒ String
Render a slide.
-
#resize(width, height) ⇒ Slideck::Renderer
Create a Renderer with a new screen size.
Constructor Details
#initialize(converter, ansi, cursor, width: nil, height: nil) ⇒ Renderer
Create a Renderer instance
32 33 34 35 36 37 38 39 40 |
# File 'lib/slideck/renderer.rb', line 32 def initialize(converter, ansi, cursor, width: nil, height: nil) @converter = converter @ansi = ansi @cursor = cursor @width = width @height = height freeze end |
Instance Attribute Details
#cursor ⇒ TTY::Cursor (readonly)
The terminal cursor
16 17 18 |
# File 'lib/slideck/renderer.rb', line 16 def cursor @cursor end |
Instance Method Details
#clear ⇒ String
Clear terminal screen
94 95 96 |
# File 'lib/slideck/renderer.rb', line 94 def clear cursor.clear_screen + cursor.move_to(0, 0) end |
#render(metadata, slide, current_num, num_of_slides) ⇒ String
Render a slide
76 77 78 79 80 81 82 83 84 |
# File 'lib/slideck/renderer.rb', line 76 def render(, , current_num, ) = && [:metadata] [].tap do |out| out << render_content(, ) if out << (, ) out << render_pager(, , current_num, ) end.join end |
#resize(width, height) ⇒ Slideck::Renderer
Create a Renderer with a new screen size
55 56 57 |
# File 'lib/slideck/renderer.rb', line 55 def resize(width, height) self.class.new(@converter, @ansi, @cursor, width: width, height: height) end |