class XLSXToHTML::Renderer
Constants
- ALLOWED_KEYS
Public Class Methods
new(data)
click to toggle source
# File lib/xlsx_to_html/renderer.rb, line 7 def initialize(data) @headers = data[:headers] @rows = data[:rows] end
Public Instance Methods
render(key: nil)
click to toggle source
# 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
Private Instance Methods
template_content(key = nil)
click to toggle source
# File lib/xlsx_to_html/renderer.rb, line 21 def template_content(key = nil) template_path = template raise ArgumentError, "invalid key: #{key}" if !common_template? && !ALLOWED_KEYS.include?(key) template_path = public_send("#{key}_template") unless common_template? File.read template_path end