Module: Erubis::Converter

Included in:
Basic::Converter, PI::Converter
Defined in:
lib/erubis/converter.rb

Overview

convert

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#escapeObject

Returns the value of attribute escape.



16
17
18
# File 'lib/erubis/converter.rb', line 16

def escape
  @escape
end

#postambleObject

Returns the value of attribute postamble.



16
17
18
# File 'lib/erubis/converter.rb', line 16

def postamble
  @postamble
end

#preambleObject

Returns the value of attribute preamble.



16
17
18
# File 'lib/erubis/converter.rb', line 16

def preamble
  @preamble
end

Class Method Details

.supported_propertiesObject

:nodoc:



18
19
20
21
22
23
24
# File 'lib/erubis/converter.rb', line 18

def self.supported_properties    # :nodoc:
  return [
          [:preamble,  nil,    "preamble (no preamble when false)"],
          [:postamble, nil,    "postamble (no postamble when false)"],
          [:escape,    nil,    "escape expression or not in default"],
         ]
end

Instance Method Details

#convert(input) ⇒ Object

convert input string into target language



33
34
35
36
37
38
39
40
# File 'lib/erubis/converter.rb', line 33

def convert(input)
  codebuf = ""    # or []
  @preamble.nil? ? add_preamble(codebuf) : (@preamble && (codebuf << @preamble))
  convert_input(codebuf, input)
  @postamble.nil? ? add_postamble(codebuf) : (@postamble && (codebuf << @postamble))
  @_proc = nil    # clear cached proc object
  return codebuf  # or codebuf.join()
end

#init_converter(properties = {}) ⇒ Object



26
27
28
29
30
# File 'lib/erubis/converter.rb', line 26

def init_converter(properties={})
  @preamble  = properties[:preamble]
  @postamble = properties[:postamble]
  @escape    = properties[:escape]
end