Class: Gooby::SimpleXmlParser

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeSimpleXmlParser

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_countObject

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_tagsObject

Returns the value of attribute watched_tags.



20
21
22
# File 'lib/gooby_simple_xml_parser.rb', line 20

def watched_tags
  @watched_tags
end

Instance Method Details

#dumpObject

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