Class: Saxon::Serializer::OutputProperties::Accessor Private

Inherits:
Object
  • Object
show all
Defined in:
lib/saxon/serializer/output_properties.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The private wrapper class that manages getting and setting output properties on a Serializer in an idiomatic Ruby-like way.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s9_serializer) ⇒ Accessor

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 Accessor.



41
42
43
# File 'lib/saxon/serializer/output_properties.rb', line 41

def initialize(s9_serializer)
  @s9_serializer = s9_serializer
end

Instance Attribute Details

#s9_serializerObject (readonly)

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.



38
39
40
# File 'lib/saxon/serializer/output_properties.rb', line 38

def s9_serializer
  @s9_serializer
end

Class Method Details

.output_propertiesObject

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.

Provides mapping between symbols and the underlying Saxon property instances



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/saxon/serializer/output_properties.rb', line 25

def self.output_properties
  @output_properties ||= Hash[
    Saxon::S9API::Serializer::Property.values.map { |property|
      qname = property.getQName
      key = [
        qname.getPrefix,
        qname.getLocalName.tr('-', '_')
      ].reject { |str| str == '' }.join('_').to_sym
      [key, property]
    }
  ]
end

Instance Method Details

#[](property) ⇒ 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.

Parameters:

  • property (Symbol, Saxon::S9API::Serializer::Property)

    The property to fetch



46
47
48
# File 'lib/saxon/serializer/output_properties.rb', line 46

def [](property)
  s9_serializer.getOutputProperty(resolved_property(property))
end

#[]=(property, value) ⇒ 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.

Parameters:

  • property (Symbol, Saxon::S9API::Serializer::Property)

    The property to set

  • value (String)

    The string value of the property



52
53
54
# File 'lib/saxon/serializer/output_properties.rb', line 52

def []=(property, value)
  s9_serializer.setOutputProperty(resolved_property(property), value)
end

#fetch(property) ⇒ Object #fetch(property, default) ⇒ 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.

Overloads:

  • #fetch(property) ⇒ Object

    Parameters:

    • property (Symbol, Saxon::S9API::Serializer::Property)

      The property to fetch

  • #fetch(property, default) ⇒ Object

    Parameters:

    • property (Symbol, Saxon::S9API::Serializer::Property)

      The property to fetch

    • default (Object)

      The value to return if the property is unset



61
62
63
64
65
66
67
68
# File 'lib/saxon/serializer/output_properties.rb', line 61

def fetch(property, default = nil)
  explicit_value = self[property]
  if explicit_value.nil? && !default.nil?
    default
  else
    explicit_value
  end
end