Class: XLSXToHTML::Renderer

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/xlsx_to_html/renderer.rb

Constant Summary collapse

ALLOWED_KEYS =
%i[headers rows].freeze

Instance Method Summary collapse

Methods included from Helpers

#method_missing, #respond_to_missing?

Constructor Details

#initialize(data) ⇒ Renderer

Returns a new instance of Renderer.



7
8
9
10
# File 'lib/xlsx_to_html/renderer.rb', line 7

def initialize(data)
  @headers = data[:headers]
  @rows = data[:rows]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class XLSXToHTML::Helpers

Instance Method Details

#render(key: nil) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
# File 'lib/xlsx_to_html/renderer.rb', line 12

def render(key: nil)
  return if without_headers? && key.eql?(:headers) && !common_template?
  raise ArgumentError, 'missing keyword: key' if !common_template? && !key

  ERB.new(template_content(key), nil, '-').result(binding)
end