Class: Nazar::View
Instance Method Summary collapse
- #horizontal? ⇒ Boolean
-
#initialize(data, layout:, use_generic_formatter: false) ⇒ View
constructor
A new instance of View.
- #layout ⇒ Object
- #render ⇒ Object
- #supported_data? ⇒ Boolean
Constructor Details
#initialize(data, layout:, use_generic_formatter: false) ⇒ View
Returns a new instance of View.
9 10 11 12 13 |
# File 'lib/nazar/view.rb', line 9 def initialize(data, layout:, use_generic_formatter: false) @data = data @use_generic_formatter = use_generic_formatter @layout = layout end |
Instance Method Details
#horizontal? ⇒ Boolean
40 41 42 |
# File 'lib/nazar/view.rb', line 40 def horizontal? layout == :horizontal end |
#layout ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/nazar/view.rb', line 27 def layout case @layout when :auto determine_layout when :vertical :vertical when :horizontal :horizontal else raise ArgumentError, "Unknown layout: #{Nazar.config.formatter.layout}" end end |
#render ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/nazar/view.rb', line 15 def render return unless supported_data? table.add_summary(summary) if summary table.render end |
#supported_data? ⇒ Boolean
23 24 25 |
# File 'lib/nazar/view.rb', line 23 def supported_data? !!formatter_klass && formatter.valid? end |