Class: Liquidscript::Buffer
- Inherits:
-
Object
- Object
- Liquidscript::Buffer
- Defined in:
- lib/liquidscript/buffer.rb
Instance Method Summary collapse
- #append(*a) ⇒ Object (also: #<<, #push)
- #block(str) ⇒ Object
-
#initialize(*args) ⇒ Buffer
constructor
A new instance of Buffer.
- #inspect ⇒ Object
- #set_join!(to) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Buffer
Returns a new instance of Buffer.
4 5 6 7 8 |
# File 'lib/liquidscript/buffer.rb', line 4 def initialize(*args) @_buf = args @_cache = nil @_join = '' end |
Instance Method Details
#append(*a) ⇒ Object Also known as: <<, push
10 11 12 13 14 |
# File 'lib/liquidscript/buffer.rb', line 10 def append(*a) @_cache = nil @_buf.push(*a) self end |
#block(str) ⇒ Object
16 17 18 |
# File 'lib/liquidscript/buffer.rb', line 16 def block(str) append str.gsub(/^[ \t]+/, '') end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/liquidscript/buffer.rb', line 33 def inspect to_s.inspect end |
#set_join!(to) ⇒ Object
20 21 22 |
# File 'lib/liquidscript/buffer.rb', line 20 def set_join!(to) @_join = to end |
#to_s ⇒ Object
27 28 29 30 31 |
# File 'lib/liquidscript/buffer.rb', line 27 def to_s @_cache ||= begin @_buf.join @_join end end |