Class: DataSpork::XmlWriter
- Inherits:
-
BaseWriter
- Object
- BaseWriter
- DataSpork::XmlWriter
- Defined in:
- lib/data_spork/xml_writer.rb
Instance Attribute Summary
Attributes inherited from BaseWriter
Instance Method Summary collapse
- #begin_put_row ⇒ Object
-
#begin_row ⇒ Object
Answer the tag defining a row.
-
#begin_tag(h = nil) ⇒ Object
Answer a begin tag using the current header, or else override it with the sender’s tag.
-
#build_schema_tag ⇒ Object
Output the schema with the root tag.
- #end_put_row ⇒ Object
-
#end_row ⇒ Object
Answer the closing tag for the current row.
-
#end_tag(h = nil) ⇒ Object
Answer the end tag using the current header, or else override it with the sender’s tag.
-
#finish ⇒ Object
Close out the XML document.
-
#indent(level = 1) ⇒ Object
Answer a string prefix for the specified indent level.
-
#put_column ⇒ Object
Output the current column enclosing it with XML tags.
-
#put_tag(tag, value) ⇒ Object
Output the value enclosing it with the specified XML tag.
- #schema_uri ⇒ Object
-
#start_document ⇒ Object
Output the XML document preface.
-
#start_schema ⇒ Object
Output the schema with the root tag.
Methods inherited from BaseWriter
#initialize, #start, #started?
Constructor Details
This class inherits a constructor from DataSpork::BaseWriter
Instance Method Details
#begin_put_row ⇒ Object
28 29 30 |
# File 'lib/data_spork/xml_writer.rb', line 28 def begin_put_row print "#{indent}#{begin_row}" end |
#begin_row ⇒ Object
Answer the tag defining a row.
59 60 61 |
# File 'lib/data_spork/xml_writer.rb', line 59 def begin_row begin_tag(row_tag) end |
#begin_tag(h = nil) ⇒ Object
Answer a begin tag using the current header, or else override it with the sender’s tag.
49 50 51 |
# File 'lib/data_spork/xml_writer.rb', line 49 def begin_tag(h = nil) "<#{h || header}>" end |
#build_schema_tag ⇒ Object
Output the schema with the root tag.
15 16 17 |
# File 'lib/data_spork/xml_writer.rb', line 15 def build_schema_tag %Q(#{root_tag} #{schema_uri} effective_date="#{effective_date}") end |
#end_put_row ⇒ Object
32 33 34 |
# File 'lib/data_spork/xml_writer.rb', line 32 def end_put_row print "#{indent}#{end_row}" end |
#end_row ⇒ Object
Answer the closing tag for the current row.
64 65 66 |
# File 'lib/data_spork/xml_writer.rb', line 64 def end_row end_tag(row_tag) end |
#end_tag(h = nil) ⇒ Object
Answer the end tag using the current header, or else override it with the sender’s tag.
54 55 56 |
# File 'lib/data_spork/xml_writer.rb', line 54 def end_tag(h = nil) "</#{h || header}>" end |
#finish ⇒ Object
Close out the XML document.
24 25 26 |
# File 'lib/data_spork/xml_writer.rb', line 24 def finish print end_tag root_tag if started? end |
#indent(level = 1) ⇒ Object
Answer a string prefix for the specified indent level.
70 71 72 |
# File 'lib/data_spork/xml_writer.rb', line 70 def indent(level = 1) "\t" * level end |
#put_column ⇒ Object
Output the current column enclosing it with XML tags.
44 45 46 |
# File 'lib/data_spork/xml_writer.rb', line 44 def put_column print "#{indent 2}#{begin_tag}#{col_value}#{end_tag}" end |
#put_tag(tag, value) ⇒ Object
Output the value enclosing it with the specified XML tag.
39 40 41 |
# File 'lib/data_spork/xml_writer.rb', line 39 def put_tag(tag, value) print "#{indent 2}#{begin_tag tag}#{value || ''}#{end_tag tag}" end |
#schema_uri ⇒ Object
19 20 21 |
# File 'lib/data_spork/xml_writer.rb', line 19 def schema_uri %q(xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance") end |
#start_document ⇒ Object
Output the XML document preface.
4 5 6 7 |
# File 'lib/data_spork/xml_writer.rb', line 4 def start_document print '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>' start_schema end |
#start_schema ⇒ Object
Output the schema with the root tag.
10 11 12 |
# File 'lib/data_spork/xml_writer.rb', line 10 def start_schema print begin_tag(build_schema_tag) end |