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.



508
509
510
511
512
513
514
515
# File 'lib/erb.rb', line 508

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

Instance Attribute Details

#scriptObject (readonly)

Returns the value of attribute script.



516
517
518
# File 'lib/erb.rb', line 516

def script
  @script
end

Instance Method Details

#closeObject



528
529
530
531
532
533
534
535
# File 'lib/erb.rb', line 528

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

#crObject



522
523
524
525
526
# File 'lib/erb.rb', line 522

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

#push(cmd) ⇒ Object



518
519
520
# File 'lib/erb.rb', line 518

def push(cmd)
  @line << cmd
end