Class: Saxon::Serializer::Object
- Inherits:
-
Object
- Object
- Saxon::Serializer::Object
- Includes:
- OutputProperties
- Defined in:
- lib/saxon/serializer/object.rb
Overview
A Saxon Serializer to be used directly with XDM Values rather than being called as a Destination for a transformation.
Class Method Summary collapse
-
.create(processor) { ... } ⇒ Object
Create a serializer from the passed in
Processor
.
Instance Method Summary collapse
-
#initialize(s9_serializer, &block) ⇒ Object
constructor
private
A new instance of Object.
- #serialize(xdm_value, io_or_path = nil) ⇒ Object
-
#to_java ⇒ Saxon::S9API::Serializer
The underlying Saxon Serializer object.
Methods included from OutputProperties
Constructor Details
#initialize(s9_serializer, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Object.
31 32 33 34 35 36 |
# File 'lib/saxon/serializer/object.rb', line 31 def initialize(s9_serializer, &block) @s9_serializer = s9_serializer if block_given? instance_exec(&block) end end |
Class Method Details
.create(processor) { ... } ⇒ Object
Create a serializer from the passed in Processor
. When called with a block, the block will be executed via instance-exec so that output properties can be set, e.g.
Serializer::Object.create(processor) {
output_property[:indent] = 'yes'
}
21 22 23 |
# File 'lib/saxon/serializer/object.rb', line 21 def self.create(processor, &block) new(processor.to_java.newSerializer, &block) end |
Instance Method Details
#serialize(xdm_value, io) ⇒ nil #serialize(xdm_value, path) ⇒ nil #serialize(xdm_value) ⇒ String
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/saxon/serializer/object.rb', line 52 def serialize(xdm_value, io_or_path = nil) case io_or_path when nil serialize_to_string(xdm_value) when String, Pathname serialize_to_file(xdm_value, io_or_path) else serialize_to_io(xdm_value, io_or_path) end end |
#to_java ⇒ Saxon::S9API::Serializer
Returns The underlying Saxon Serializer object.
64 65 66 |
# File 'lib/saxon/serializer/object.rb', line 64 def to_java s9_serializer end |