Class: ERB::Compiler::Buffer

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compiler, enc = nil) ⇒ Buffer

Returns a new instance of Buffer.



549
550
551
552
553
554
555
556
# File 'lib/erb.rb', line 549

def initialize(compiler, enc=nil)
  @compiler = compiler
  @line = []
  @script = enc ? "#coding:#{enc}\n" : ""
  @compiler.pre_cmd.each do |x|
    push(x)
  end
end

Instance Attribute Details

#scriptObject (readonly)

Returns the value of attribute script



557
558
559
# File 'lib/erb.rb', line 557

def script
  @script
end

Instance Method Details

#closeObject



569
570
571
572
573
574
575
576
# File 'lib/erb.rb', line 569

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

#crObject



563
564
565
566
567
# File 'lib/erb.rb', line 563

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

#push(cmd) ⇒ Object



559
560
561
# File 'lib/erb.rb', line 559

def push(cmd)
  @line << cmd
end