class Converter
BUILD_IN_CONVERTERS = [
# build-in converters from this https://github.com/pythonicrubyist/creek/blob/master/lib/creek/styles/converter.rb#L41
]
def initialize(custom_converters: [])
@_converters = custom_converters + BUILD_IN_CONVERTERS
end
def call(value, type, style, options = {})
@_converters.each do |converter|
if converter.is_support?(value, type, style, options)
return converter.convert(value, type, style, options)
end
end
raise StandardError, "Not found converter for cell #{options[:cell_name].to_s} with type #{type.to_s} and style #{style.to_s}"
end
end
Base value converter class
class Base
def is_support?(value, type, style, options)
false
end
def convert(value, type, style, options)
raise NotImplementedError
end
end
and pass to options cell name, sheet name, and raw sharing strings (in my case need to convert them to HTML with styles)
I propose to make the converter this way:
Base value converter class
and pass to options cell name, sheet name, and raw sharing strings (in my case need to convert them to HTML with styles)