Class: Leptris::XML::ParseOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/leptris/xml/parse_options.rb

Overview

Parser flags, mirroring LeptrisParseFlags in libleptris's public headers. Pass an instance as Leptris::XML.parse(xml, options:).

Constant Summary collapse

NOBLANKS =

Discard whitespace-only text nodes (runs between tags that contain nothing but spaces/tabs/newlines). Matches libxml2's XML_PARSE_NOBLANKS and Nokogiri's noblanks. Documents parsed this way do not round-trip pretty-printed formatting byte-for-byte.

Leptris::XML::FFI::LEPTRIS_PARSE_DROP_WS_TEXT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flags = Leptris::XML::FFI::LEPTRIS_PARSE_DEFAULT) ⇒ ParseOptions

Returns a new instance of ParseOptions.



14
15
16
# File 'lib/leptris/xml/parse_options.rb', line 14

def initialize(flags = Leptris::XML::FFI::LEPTRIS_PARSE_DEFAULT)
  @flags = flags.to_i
end

Instance Attribute Details

#flagsObject (readonly)

Returns the value of attribute flags.



12
13
14
# File 'lib/leptris/xml/parse_options.rb', line 12

def flags
  @flags
end

Class Method Details

.noblanksObject



18
19
20
# File 'lib/leptris/xml/parse_options.rb', line 18

def self.noblanks
  new(NOBLANKS)
end

Instance Method Details

#noblanks?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/leptris/xml/parse_options.rb', line 22

def noblanks?
  @flags & NOBLANKS != 0
end

#|(other) ⇒ Object



26
27
28
# File 'lib/leptris/xml/parse_options.rb', line 26

def |(other)
  self.class.new(@flags | other.flags)
end