# ERB (Class)

In: | erb.rb
Parent: | Object

ERB::DefMethod

## Methods

def_class def_method def_module new result run set_eoutvar version

## Constants

Revision | = | '$Date: 2003/12/10 09:07:52 $'

## Attributes

filename | [RW] |
src | [R] |

## Classes and Modules

Module ERB::DefMethod
Module ERB::Util
Class ERB::Compiler
::Class ERB::Compiler::Buffer
::Class ERB::Compiler::ExplicitScanner
::Class ERB::Compiler::PercentLine
::Class ERB::Compiler::PercentScanner
::Class ERB::Compiler::Scanner
::Class ERB::Compiler::SimpleScanner
::Class ERB::Compiler::SimpleScanner2
::Class ERB::Compiler::TrimScanner

## Public Class methods

version()

[Source]

    # File erb.rb, line 8
      def self.version
        "erb.rb [2.0.4 #{ERB::Revision.split[1]}]"
      end

new(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout')

[Source]

    # File erb.rb, line 385
      def initialize(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout')
        @safe_level = safe_level
        compiler = ERB::Compiler.new(trim_mode)
        set_eoutvar(compiler, eoutvar)
        @src = compiler.compile(str)
        @filename = nil
      end

## Public Instance methods

set_eoutvar(compiler, eoutvar = '_erbout')

[Source]

    # File erb.rb, line 395
      def set_eoutvar(compiler, eoutvar = '_erbout')
        compiler.put_cmd = "#{eoutvar}.concat"

        cmd = []
        cmd.push "#{eoutvar} = ''"

        compiler.pre_cmd = cmd

        cmd = []
        cmd.push(eoutvar)

        compiler.post_cmd = cmd
      end

run(b=TOPLEVEL_BINDING)

[Source]

    # File erb.rb, line 409
      def run(b=TOPLEVEL_BINDING)
        print self.result(b)
      end

result(b=TOPLEVEL_BINDING)

[Source]

    # File erb.rb, line 413
      def result(b=TOPLEVEL_BINDING)
        if @safe_level
          th = Thread.start {
            $SAFE = @safe_level
            eval(@src, b)
          }
          return th.value
        else
          return eval(@src, b, (@filename || '(erb)'), 1)
        end
      end

def_method(mod, methodname, fname='(ERB)')

[Source]

    # File erb.rb, line 425
      def def_method(mod, methodname, fname='(ERB)')
        mod.module_eval("def #{methodname}\n" + self.src + "\nend\n", fname, 0)
      end

def_module(methodname='erb')

[Source]

    # File erb.rb, line 429
      def def_module(methodname='erb')
        mod = Module.new
        def_method(mod, methodname)
        mod
      end

def_class(superklass=Object, methodname='result')

[Source]

    # File erb.rb, line 435
      def def_class(superklass=Object, methodname='result')
        cls = Class.new(superklass)
        def_method(cls, methodname)
        cls
      end

[Validate]