Class: Saxerator::Adapters::Ox
- Inherits:
-
Object
- Object
- Saxerator::Adapters::Ox
- Extended by:
- Forwardable
- Defined in:
- lib/saxerator/adapters/ox.rb
Overview
< ::Ox::Sax
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#name ⇒ Object
Returns the value of attribute name.
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
Class Method Summary collapse
Instance Method Summary collapse
- #attr(name, value) ⇒ Object
- #end_element(name) ⇒ Object
- #error(message, _, _) ⇒ Object
- #guard! ⇒ Object
-
#initialize(reader) ⇒ Ox
constructor
A new instance of Ox.
- #start_element(name) ⇒ Object
- #text(str) ⇒ Object (also: #cdata)
Constructor Details
#initialize(reader) ⇒ Ox
Returns a new instance of Ox.
18 19 20 21 22 23 |
# File 'lib/saxerator/adapters/ox.rb', line 18 def initialize(reader) @reader = reader @attributes = {} @name = '' end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
15 16 17 |
# File 'lib/saxerator/adapters/ox.rb', line 15 def attributes @attributes end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/saxerator/adapters/ox.rb', line 14 def name @name end |
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
16 17 18 |
# File 'lib/saxerator/adapters/ox.rb', line 16 def reader @reader end |
Class Method Details
.parse(source, reader) ⇒ Object
9 10 11 12 |
# File 'lib/saxerator/adapters/ox.rb', line 9 def self.parse(source, reader) handler = new(reader) ::Ox.sax_parse(handler, source) end |
Instance Method Details
#attr(name, value) ⇒ Object
30 31 32 |
# File 'lib/saxerator/adapters/ox.rb', line 30 def attr(name, value) attributes[name.to_s] = value end |
#end_element(name) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/saxerator/adapters/ox.rb', line 42 def end_element(name) guard! name = name.to_s name = strip_namespace(name) if reader.ignore_namespaces? reader.end_element(name) end |
#error(message, _, _) ⇒ Object
57 58 59 |
# File 'lib/saxerator/adapters/ox.rb', line 57 def error(, _, _) raise Saxerator::ParseException, end |
#guard! ⇒ Object
25 26 27 28 |
# File 'lib/saxerator/adapters/ox.rb', line 25 def guard! reader.start_element(name, attributes.to_a) unless name.empty? reset! end |
#start_element(name) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/saxerator/adapters/ox.rb', line 34 def start_element(name) guard! name = name.to_s name = strip_namespace(name) if reader.ignore_namespaces? self.name = name end |
#text(str) ⇒ Object Also known as: cdata
50 51 52 53 |
# File 'lib/saxerator/adapters/ox.rb', line 50 def text(str) guard! reader.characters(str) end |