Class: Gooby::SimpleXmlParser
- Inherits:
-
Object
- Object
- Gooby::SimpleXmlParser
- Includes:
- REXML::StreamListener
- Defined in:
- lib/gooby_simple_xml_parser.rb
Overview
Sample implementation of a REXML::StreamListener SAX parser.
This class isn't actually used in Gooby, but is retained for future use.
Instance Attribute Summary collapse
-
#tag_count ⇒ Object
Returns the value of attribute tag_count.
-
#watched_tags ⇒ Object
Returns the value of attribute watched_tags.
Instance Method Summary collapse
-
#dump ⇒ Object
Prints the state of this object (the counter hash).
-
#initialize ⇒ SimpleXmlParser
constructor
A new instance of SimpleXmlParser.
-
#tag_end(tagname) ⇒ Object
SAX API method.
-
#tag_start(tag_name, attrs) ⇒ Object
SAX API method.
-
#text(txt) ⇒ Object
SAX API method.
Constructor Details
#initialize ⇒ SimpleXmlParser
Returns a new instance of SimpleXmlParser.
22 23 24 25 |
# File 'lib/gooby_simple_xml_parser.rb', line 22 def initialize @tag_count = 0 @counter_hash = CounterHash.new end |
Instance Attribute Details
#tag_count ⇒ Object
Returns the value of attribute tag_count.
20 21 22 |
# File 'lib/gooby_simple_xml_parser.rb', line 20 def tag_count @tag_count end |
#watched_tags ⇒ Object
Returns the value of attribute watched_tags.
20 21 22 |
# File 'lib/gooby_simple_xml_parser.rb', line 20 def @watched_tags end |
Instance Method Details
#dump ⇒ Object
Prints the state of this object (the counter hash).
44 45 46 |
# File 'lib/gooby_simple_xml_parser.rb', line 44 def dump puts @counter_hash.to_s end |
#tag_end(tagname) ⇒ Object
SAX API method. No impl.
36 37 |
# File 'lib/gooby_simple_xml_parser.rb', line 36 def tag_end(tagname) end |
#tag_start(tag_name, attrs) ⇒ Object
SAX API method. Increments the tagname in the counter hash.
30 31 32 33 |
# File 'lib/gooby_simple_xml_parser.rb', line 30 def tag_start(tag_name, attrs) @tag_count = @tag_count + 1 @counter_hash.increment(tag_name) end |
#text(txt) ⇒ Object
SAX API method. No impl.
40 41 |
# File 'lib/gooby_simple_xml_parser.rb', line 40 def text(txt) end |