Class: ERB::Compiler::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/erb/compiler.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compiler, enc = nil, frozen = nil) ⇒ Buffer

Returns a new instance of Buffer.



279
280
281
282
283
284
285
286
287
288
# File 'lib/erb/compiler.rb', line 279

def initialize(compiler, enc=nil, frozen=nil)
  @compiler = compiler
  @line = []
  @script = +''
  @script << "#coding:#{enc}\n" if enc
  @script << "#frozen-string-literal:#{frozen}\n" unless frozen.nil?
  @compiler.pre_cmd.each do |x|
    push(x)
  end
end

Instance Attribute Details

#scriptObject (readonly)

Returns the value of attribute script.



289
290
291
# File 'lib/erb/compiler.rb', line 289

def script
  @script
end

Instance Method Details

#closeObject



301
302
303
304
305
306
307
308
# File 'lib/erb/compiler.rb', line 301

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

#crObject



295
296
297
298
299
# File 'lib/erb/compiler.rb', line 295

def cr
  @script << (@line.join('; '))
  @line = []
  @script << "\n"
end

#push(cmd) ⇒ Object



291
292
293
# File 'lib/erb/compiler.rb', line 291

def push(cmd)
  @line << cmd
end