Class: ERB::HamlCompiler::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/haml/herb.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compiler, delimiter) ⇒ Buffer

Returns a new instance of Buffer.



5
6
7
8
9
10
11
12
13
# File 'lib/haml/herb.rb', line 5

def initialize(compiler, delimiter)
  @compiler = compiler
  @line = []
  @script = ""
  @delimiter = delimiter
  @compiler.pre_cmd.each do |x|
    push(x)
  end
end

Instance Attribute Details

#scriptObject (readonly)

Returns the value of attribute script.



14
15
16
# File 'lib/haml/herb.rb', line 14

def script
  @script
end

Instance Method Details

#closeObject



26
27
28
29
30
31
32
33
# File 'lib/haml/herb.rb', line 26

def close
  return unless @line
  @compiler.post_cmd.each do |x|
    push(x)
  end
  @script << (@line.join(@delimiter))
  @line = nil
end

#crObject



20
21
22
23
24
# File 'lib/haml/herb.rb', line 20

def cr
  @script << (@line.join(@delimiter))
  @line = []
  @script << @delimiter
end

#push(cmd) ⇒ Object



16
17
18
# File 'lib/haml/herb.rb', line 16

def push(cmd)
  @line << cmd
end