Sha256: 1cdd1bda3819805d661ecf8b616f5ff81a9e4398593facf0584e51b7f7104a4d
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true module LiquidDiagrams # @abstract Subclass and override {#render} to implement. class BasicRenderer include Rendering # Configuration key for argument with boolean value. FLAGS = [].freeze # Prefix for {FLAGS} FLAGS_PREFIX = '--' # Configuration key for argument with key-value pairs. OPTIONS = [].freeze # Separator for key and value of {OPTIONS}. OPTIONS_SEPARATOR = ' ' # Prefix for {OPTIONS} OPTIONS_PREFIX = '--' def self.render(content, options = {}) new(content, options).render end def initialize(content, options = {}) @content = content @config = options end # Default render method with {Errors::NotImplementedError} raised # # @important You should overrite this method in your own renderer class def render raise Errors::NotImplementedError end def build_command "#{executable} #{arguments}".strip end def executable self.class.name.split('::').last.sub(/Renderer$/, '').downcase end def arguments flags = Utils.build_flags( @config, self.class.const_get(:FLAGS), prefix: self.class.const_get(:FLAGS_PREFIX) ) options = Utils.build_options( @config, self.class.const_get(:OPTIONS), prefix: self.class.const_get(:OPTIONS_PREFIX), sep: self.class.const_get(:OPTIONS_SEPARATOR) ) "#{flags} #{options}".strip end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
liquid-diagrams-0.4.0 | lib/liquid_diagrams/basic_renderer.rb |