Class: ErbPP::ERBLN
- Inherits:
-
Object
- Object
- ErbPP::ERBLN
- Defined in:
- ext/numo/narray/gen/erbln.rb
Instance Method Summary collapse
-
#initialize(str, filename, trim_mode = nil, eoutvar = '_erbout') ⇒ ERBLN
constructor
A new instance of ERBLN.
- #result(b) ⇒ Object
- #run(b) ⇒ Object
- #set_eoutvar(compiler, eoutvar = '_erbout') ⇒ Object
Constructor Details
#initialize(str, filename, trim_mode = nil, eoutvar = '_erbout') ⇒ ERBLN
Returns a new instance of ERBLN.
102 103 104 105 106 107 |
# File 'ext/numo/narray/gen/erbln.rb', line 102 def initialize(str, filename, trim_mode=nil, eoutvar='_erbout') @filename = filename compiler = ERB::Compiler.new(trim_mode) set_eoutvar(compiler, eoutvar) @src, @enc = *compiler.compile(str) end |
Instance Method Details
#result(b) ⇒ Object
120 121 122 123 124 125 126 |
# File 'ext/numo/narray/gen/erbln.rb', line 120 def result(b) #open("tmpout","a") do |f| # f.puts "\n#file:#{@filename}" # f.puts @src #end eval(@src, b, (@filename || '(erb)'), 0) end |
#run(b) ⇒ Object
116 117 118 |
# File 'ext/numo/narray/gen/erbln.rb', line 116 def run(b) print self.result(b) end |
#set_eoutvar(compiler, eoutvar = '_erbout') ⇒ Object
109 110 111 112 113 114 |
# File 'ext/numo/narray/gen/erbln.rb', line 109 def set_eoutvar(compiler, eoutvar = '_erbout') compiler.put_cmd = "#{eoutvar}.concat0" compiler.insert_cmd = "#{eoutvar}.concat1" compiler.pre_cmd = ["#{eoutvar} = CountLnString.new(#{@filename.inspect})"] compiler.post_cmd = ["#{eoutvar}.final"] end |