Class: BerkeleyLibrary::Util::ODS::XML::DocumentNode
- Inherits:
-
Object
- Object
- BerkeleyLibrary::Util::ODS::XML::DocumentNode
- Defined in:
- lib/berkeley_library/util/ods/xml/document_node.rb
Direct Known Subclasses
Constant Summary collapse
- ENCODING =
'UTF-8'.freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(path) ⇒ DocumentNode
constructor
Initializes a new DocumentNode.
- #to_xml(out = nil, compact: true) ⇒ Object
Constructor Details
#initialize(path) ⇒ DocumentNode
Initializes a new DocumentNode
15 16 17 |
# File 'lib/berkeley_library/util/ods/xml/document_node.rb', line 15 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/berkeley_library/util/ods/xml/document_node.rb', line 11 def path @path end |
Instance Method Details
#doc ⇒ Object
26 27 28 29 30 |
# File 'lib/berkeley_library/util/ods/xml/document_node.rb', line 26 def doc @doc ||= Nokogiri::XML::Document.new.tap do |doc| doc.encoding = ENCODING end end |
#to_xml(out = nil, compact: true) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/berkeley_library/util/ods/xml/document_node.rb', line 19 def to_xml(out = nil, compact: true) return write_xml_to_string(compact: compact) unless out return write_xml_to_stream(out, compact: compact) if out.respond_to?(:write) write_xml_to_file(out, compact: compact) end |