Class: Parser::XMLBuilderEngine
- Inherits:
-
Object
- Object
- Parser::XMLBuilderEngine
- Defined in:
- lib/kuniri/parser/xml_builder_engine.rb
Instance Attribute Summary collapse
-
#betweenTag ⇒ Object
readonly
Returns the value of attribute betweenTag.
-
#ident ⇒ Object
readonly
Returns the value of attribute ident.
-
#identIncrement ⇒ Object
Returns the value of attribute identIncrement.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
-
#initialize(pBaseSpaceIdent = 2) ⇒ XMLBuilderEngine
constructor
A new instance of XMLBuilderEngine.
- #reset_engine ⇒ Object
- #set_default(pBaseSpaceIdent = 2) ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(pBaseSpaceIdent = 2) ⇒ XMLBuilderEngine
Returns a new instance of XMLBuilderEngine.
12 13 14 |
# File 'lib/kuniri/parser/xml_builder_engine.rb', line 12 def initialize(pBaseSpaceIdent = 2) set_default(pBaseSpaceIdent) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(pTagName, *pTagParameters, &pBlock) ⇒ Object (private)
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/kuniri/parser/xml_builder_engine.rb', line 35 def method_missing(pTagName, *pTagParameters, &pBlock) @tag += "\n" unless @tag.strip == '' currentTagName = "#{@ident}<#{pTagName.to_s}" @tag << currentTagName if pTagParameters.size > 0 and pTagParameters[0].is_a? Hash handleArguments(pTagParameters) end if block_given? @tag << ">\n" incrementIdentation result = instance_eval(&pBlock) if result != '' && result.is_a?(String) updateTag(result) end decrementIdent @tag << "#{@ident}</#{pTagName.to_s}>\n" @tag.squeeze!("\n") else @tag << "/>\n" end @content = '' end |
Instance Attribute Details
#betweenTag ⇒ Object (readonly)
Returns the value of attribute betweenTag.
6 7 8 |
# File 'lib/kuniri/parser/xml_builder_engine.rb', line 6 def betweenTag @betweenTag end |
#ident ⇒ Object (readonly)
Returns the value of attribute ident.
7 8 9 |
# File 'lib/kuniri/parser/xml_builder_engine.rb', line 7 def ident @ident end |
#identIncrement ⇒ Object
Returns the value of attribute identIncrement.
8 9 10 |
# File 'lib/kuniri/parser/xml_builder_engine.rb', line 8 def identIncrement @identIncrement end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
5 6 7 |
# File 'lib/kuniri/parser/xml_builder_engine.rb', line 5 def tag @tag end |
Instance Method Details
#reset_engine ⇒ Object
20 21 22 23 |
# File 'lib/kuniri/parser/xml_builder_engine.rb', line 20 def reset_engine @tag = nil set_default end |
#set_default(pBaseSpaceIdent = 2) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/kuniri/parser/xml_builder_engine.rb', line 25 def set_default(pBaseSpaceIdent = 2) @tag = '<?xml version="1.0" encoding="UTF-8"?>' @baseSpaceIdentation = pBaseSpaceIdent @content = '' @ident = '' @identIncrement = ' ' * pBaseSpaceIdent end |
#to_xml ⇒ Object
16 17 18 |
# File 'lib/kuniri/parser/xml_builder_engine.rb', line 16 def to_xml return @tag end |