Sha256: 403aad77b99cfc2d5936018dfcf5bf159603cbd4c91c941f0564732e0159b036

Contents?: true

Size: 524 Bytes

Versions: 6

Compression:

Stored size: 524 Bytes

Contents

module Liquidscript
  class Buffer

    def initialize(*args)
      @_buf   = args
      @_cache = nil
      @_join  = ''
    end

    def append(*a)
      @_cache = nil
      @_buf.push(*a)
      self
    end

    def block(str)
      append str.gsub(/^[ \t]+/, '')
    end

    def set_join!(to)
      @_join = to
    end

    alias_method :<<, :append
    alias_method :push, :append

    def to_s
      @_cache ||= begin
        @_buf.join @_join
      end
    end

    def inspect
      to_s.inspect
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
liquidscript-0.4.1 lib/liquidscript/buffer.rb
liquidscript-0.4.0 lib/liquidscript/buffer.rb
liquidscript-0.3.1 lib/liquidscript/buffer.rb
liquidscript-0.3.0 lib/liquidscript/buffer.rb
liquidscript-0.2.1 lib/liquidscript/buffer.rb
liquidscript-0.2.0 lib/liquidscript/buffer.rb