Class: Saxerator::Adapters::Oga
- Inherits:
-
Object
- Object
- Saxerator::Adapters::Oga
- Extended by:
- Forwardable
- Defined in:
- lib/saxerator/adapters/oga.rb
Class Method Summary collapse
Instance Method Summary collapse
- #after_element(namespace, name) ⇒ Object
-
#initialize(reader) ⇒ Oga
constructor
A new instance of Oga.
- #on_element(namespace, name, attrs = {}) ⇒ Object
Constructor Details
#initialize(reader) ⇒ Oga
Returns a new instance of Oga.
16 17 18 19 |
# File 'lib/saxerator/adapters/oga.rb', line 16 def initialize(reader) @reader = reader @ignore_namespaces = reader.ignore_namespaces? end |
Class Method Details
.parse(source, reader) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/saxerator/adapters/oga.rb', line 9 def self.parse(source, reader) parser = ::Oga::XML::SaxParser.new(new(reader), source, strict: true) parser.parse rescue LL::ParserError => raise Saxerator::ParseException, end |
Instance Method Details
#after_element(namespace, name) ⇒ Object
30 31 32 33 |
# File 'lib/saxerator/adapters/oga.rb', line 30 def after_element(namespace, name) name = "#{namespace}:#{name}" if namespace && !@ignore_namespaces @reader.end_element(name) end |
#on_element(namespace, name, attrs = {}) ⇒ Object
24 25 26 27 28 |
# File 'lib/saxerator/adapters/oga.rb', line 24 def on_element(namespace, name, attrs = {}) name = "#{namespace}:#{name}" if namespace && !@ignore_namespaces attrs = @ignore_namespaces ? strip_namespace(attrs) : attrs.to_a @reader.start_element(name, attrs) end |