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.



273
274
275
276
277
278
279
280
281
282
# File 'lib/erb/compiler.rb', line 273

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.



283
284
285
# File 'lib/erb/compiler.rb', line 283

def script
  @script
end

Instance Method Details

#closeObject



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

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

#crObject



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

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

#push(cmd) ⇒ Object



285
286
287
# File 'lib/erb/compiler.rb', line 285

def push(cmd)
  @line << cmd
end