Class: DumpListener
- Inherits:
-
Object
- Object
- DumpListener
- Includes:
- StreamListener
- Defined in:
- lib/xmlutils/dumplistener.rb
Overview
class DumpListener
Instance Attribute Summary collapse
-
#verbose ⇒ Object
writeonly
Sets the attribute verbose.
Instance Method Summary collapse
- #entity(content) ⇒ Object
-
#initialize ⇒ DumpListener
constructor
A new instance of DumpListener.
- #tag_end(tag) ⇒ Object
- #tag_start(tag, attributes) ⇒ Object
- #text(txt) ⇒ Object
- #verbose? ⇒ Boolean
Constructor Details
#initialize ⇒ DumpListener
Returns a new instance of DumpListener.
27 28 29 |
# File 'lib/xmlutils/dumplistener.rb', line 27 def initialize() @verbose = false end |
Instance Attribute Details
#verbose=(value) ⇒ Object (writeonly)
Sets the attribute verbose
20 21 22 |
# File 'lib/xmlutils/dumplistener.rb', line 20 def verbose=(value) @verbose = value end |
Instance Method Details
#entity(content) ⇒ Object
49 50 51 |
# File 'lib/xmlutils/dumplistener.rb', line 49 def entity(content) puts "entity: #{content}" if verbose? end |
#tag_end(tag) ⇒ Object
44 45 46 47 |
# File 'lib/xmlutils/dumplistener.rb', line 44 def tag_end(tag) puts "End #{tag}" if verbose? puts "" if verbose? end |
#tag_start(tag, attributes) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/xmlutils/dumplistener.rb', line 32 def tag_start(tag, attributes) puts "Start #{tag}" unless (false == @verbose) # puts "Arry: " + attributes.inspect if(!attributes.empty?) puts " Attr:" unless (false == @verbose) attributes.each do |attr| puts " #{attr[0]}: #{attr[1]}" if verbose? end end end |
#text(txt) ⇒ Object
53 54 55 |
# File 'lib/xmlutils/dumplistener.rb', line 53 def text(txt) puts "text: #{txt}" if verbose? end |
#verbose? ⇒ Boolean
22 23 24 |
# File 'lib/xmlutils/dumplistener.rb', line 22 def verbose? @verbose end |