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, frozen = nil) ⇒ Buffer

Returns a new instance of Buffer.



542
543
544
545
546
547
548
549
550
551
# File 'lib/erb.rb', line 542

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.



552
553
554
# File 'lib/erb.rb', line 552

def script
  @script
end

Instance Method Details

#closeObject



564
565
566
567
568
569
570
571
# File 'lib/erb.rb', line 564

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

#crObject



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

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

#push(cmd) ⇒ Object



554
555
556
# File 'lib/erb.rb', line 554

def push(cmd)
  @line << cmd
end