Class: Nazar::Renderer
- Inherits:
-
Object
- Object
- Nazar::Renderer
- Defined in:
- lib/nazar/renderer.rb
Instance Method Summary collapse
-
#initialize(data, layout:, paginate:, use_generic_formatter: false) ⇒ Renderer
constructor
A new instance of Renderer.
- #pager ⇒ Object
- #render ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(data, layout:, paginate:, use_generic_formatter: false) ⇒ Renderer
Returns a new instance of Renderer.
5 6 7 8 9 10 |
# File 'lib/nazar/renderer.rb', line 5 def initialize(data, layout:, paginate:, use_generic_formatter: false) @data = data @use_generic_formatter = use_generic_formatter @layout = layout @paginate = paginate end |
Instance Method Details
#pager ⇒ Object
25 26 27 |
# File 'lib/nazar/renderer.rb', line 25 def pager @pager ||= TTY::Pager::SystemPager.new(command: 'less -iMSx4 -FXR') end |
#render ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/nazar/renderer.rb', line 12 def render if paginate || view.horizontal? pager.page(view.render) else puts view.render end nil end |
#valid? ⇒ Boolean
21 22 23 |
# File 'lib/nazar/renderer.rb', line 21 def valid? view.supported_data? end |