Class: Saxon::ParserProperties

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/saxon/parse_options.rb

Overview

Provides idiomatic access to parser properties

Instance Method Summary collapse

Constructor Details

#initialize(parse_options) ⇒ ParserProperties

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

Parameters:



40
41
42
# File 'lib/saxon/parse_options.rb', line 40

def initialize(parse_options)
  @parse_options ||= parse_options
end

Instance Method Details

#[](uri) ⇒ Object

Fetch the current value of a Parser Property

Parameters:

  • uri (String, URI)

    The Parser Property URI to fetch

Returns:

  • (Object)

    The current value of the property



53
54
55
56
# File 'lib/saxon/parse_options.rb', line 53

def [](uri)
  return nil if parse_options.getParserProperties.nil?
  parse_options.getParserProperty(uri)
end

#[]=(uri, value) ⇒ Object

Set the value of a Parser Property

Parameters:

  • uri (String, URI)

    The Parser Property URI to set

  • value (Object)

    The value to set the property to

Returns:

  • (Object)

    The new value of the property



63
64
65
66
# File 'lib/saxon/parse_options.rb', line 63

def []=(uri, value)
  parse_options.addParserProperties(uri, value)
  self[uri]
end

#each {|uri, value| ... } ⇒ Object

Iterate across each currently-set property, in the same way as a hash

Yields:

  • (uri, value)

Yield Parameters:

  • uri (String)

    The URI of the property as a String

  • value (Object)

    The value of the property



73
74
75
# File 'lib/saxon/parse_options.rb', line 73

def each(&block)
  to_h.each(&block)
end

#to_hHash

Returns the currently-set properties as a (frozen) hash.

Returns:

  • (Hash)

    the currently-set properties as a (frozen) hash



45
46
47
# File 'lib/saxon/parse_options.rb', line 45

def to_h
  (parse_options.getParserProperties || {}).freeze
end