Class: DumpListener

Inherits:
Object
  • Object
show all
Includes:
StreamListener
Defined in:
lib/xmlutils/dumplistener.rb

Overview

class DumpListener

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDumpListener

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

Parameters:

  • value

    the value to set the attribute verbose to.



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

Returns:

  • (Boolean)


22
23
24
# File 'lib/xmlutils/dumplistener.rb', line 22

def verbose?
  @verbose
end