Sha256: 5611e71236b3d5a3e2d2da40c9518cdfa2c8fa668e885f80764815ad67b12cc0

Contents?: true

Size: 719 Bytes

Versions: 2

Compression:

Stored size: 719 Bytes

Contents

module Garterbelt
  class Renderer
    attr_accessor :view
    
    def initialize(opts)
      self.view = opts[:view] || raise(ArgumentError, ":view required in initialization options")
    end
    
    # Rendering -----------------------------------------------
    def output
      view.output
    end
    
    def output=(alt_output)
      view.output = alt_output
    end
    
    def level 
      view.level
    end
    
    def style
      view.render_style
    end
    
    def indent
      style == :minified ? "" : ' '*level*2
    end
    
    def line_end
      style == :minified ?  "" : "\n"
    end
    
    def render
      raise NotImplementedError, "Subclasses must implement #render"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
garterbelt-0.0.9 lib/renderers/renderer.rb
garterbelt-0.0.8 lib/renderers/renderer.rb