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.



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

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.



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

def script
  @script
end

Instance Method Details

#closeObject



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

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

#crObject



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

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

#push(cmd) ⇒ Object



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

def push(cmd)
  @line << cmd
end