Class: Serialbench::Serializers::Xml::BaseXmlSerializer
- Inherits:
-
BaseSerializer
- Object
- BaseSerializer
- Serialbench::Serializers::Xml::BaseXmlSerializer
- Defined in:
- lib/serialbench/serializers/xml/base_xml_serializer.rb
Direct Known Subclasses
LeptrisSerializer, LibxmlSerializer, NokogiriSerializer, OgaSerializer, OxSerializer, RexmlSerializer
Class Method Summary collapse
Instance Method Summary collapse
-
#available? ⇒ Boolean
Check if the XML library is available.
- #capabilities ⇒ Object
-
#features ⇒ Object
XML-specific features derive from the capability set.
- #generate_xml(document, options = {}) ⇒ Object
-
#parse_dom(xml_string) ⇒ Object
XML-specific methods.
- #parse_sax(xml_string, &block) ⇒ Object
Methods inherited from BaseSerializer
#generate, #get_version, #initialize, #parse, #require_library, #stream_parse, #supports?
Constructor Details
This class inherits a constructor from Serialbench::Serializers::BaseSerializer
Class Method Details
.format ⇒ Object
9 10 11 |
# File 'lib/serialbench/serializers/xml/base_xml_serializer.rb', line 9 def self.format :xml end |
Instance Method Details
#available? ⇒ Boolean
Check if the XML library is available
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/serialbench/serializers/xml/base_xml_serializer.rb', line 42 def available? return @available if defined?(@available) @available = begin require library_require_name true rescue LoadError false end end |
#capabilities ⇒ Object
26 27 28 |
# File 'lib/serialbench/serializers/xml/base_xml_serializer.rb', line 26 def capabilities super | Set.new(%i[namespaces]) end |
#features ⇒ Object
XML-specific features derive from the capability set
31 32 33 34 35 36 37 38 39 |
# File 'lib/serialbench/serializers/xml/base_xml_serializer.rb', line 31 def features { xpath: supports?(:xpath), namespaces: supports?(:namespaces), validation: supports?(:validation), streaming: supports?(:sax) || supports?(:streaming), stax: supports?(:stax) } end |
#generate_xml(document, options = {}) ⇒ Object
22 23 24 |
# File 'lib/serialbench/serializers/xml/base_xml_serializer.rb', line 22 def generate_xml(document, = {}) generate(document, ) end |
#parse_dom(xml_string) ⇒ Object
XML-specific methods
14 15 16 |
# File 'lib/serialbench/serializers/xml/base_xml_serializer.rb', line 14 def parse_dom(xml_string) parse(xml_string) end |
#parse_sax(xml_string, &block) ⇒ Object
18 19 20 |
# File 'lib/serialbench/serializers/xml/base_xml_serializer.rb', line 18 def parse_sax(xml_string, &block) stream_parse(xml_string, &block) end |