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.



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

def escape
  @escape
end

#postambleObject

Returns the value of attribute postamble.



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

def postamble
  @postamble
end

#preambleObject

Returns the value of attribute preamble.



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

def preamble
  @preamble
end

Class Method Details

.supported_propertiesObject

:nodoc:



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

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



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

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



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

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