class Tabulatr::ParamsBuilder
Constants
- ALLOWED_PARAMS
- DEPRECATED_PARAMS
Public Class Methods
new(params = {})
click to toggle source
# File lib/tabulatr/params_builder.rb, line 10 def initialize(params = {}) apply_params(params) end
Public Instance Methods
update(params = {})
click to toggle source
# File lib/tabulatr/params_builder.rb, line 14 def update(params = {}) apply_params(params) end
Private Instance Methods
apply_params(params)
click to toggle source
# File lib/tabulatr/params_builder.rb, line 30 def apply_params(params) params.each do |k, v| if DEPRECATED_PARAMS.include?(k.to_sym) self.public_send(k) elsif ALLOWED_PARAMS.exclude?(k.to_sym) raise ArgumentError, "`#{k}` is not allowed as a parameter" else self.public_send("#{k}=", v) end end style_options end
apply_style_option(attribute, value)
click to toggle source
# File lib/tabulatr/params_builder.rb, line 43 def apply_style_option(attribute, value) if value.present? self.header_html[:style].concat("#{attribute}: #{value};") self.data_html[:style].concat("#{attribute}: #{value};") end end
style_options()
click to toggle source
# File lib/tabulatr/params_builder.rb, line 20 def style_options self.data_html ||= {} self.header_html ||= {} self.data_html[:style] ||= '' self.header_html[:style] ||= '' apply_style_option('text-align', align) apply_style_option('width', width) apply_style_option('white-space', wrap) end