module ThinpXML::Base::ListenerUtils
Public Instance Methods
get_fields(attr, flds)
click to toggle source
# File lib/thinp_xml/listener.rb, line 14 def get_fields(attr, flds) flds.map do |n,t| case t when :int attr[n].to_i when :bool case attr[n] when 'true' true when 'false' false else raise "bad boolean value '#{attr[n]}'" end when :string attr[n] when :object attr[n] else raise "unknown field type" end end end
text(data)
click to toggle source
# File lib/thinp_xml/listener.rb, line 42 def text(data) return if data =~ /^\w*$/ # ignore whitespace abbrev = data[0..40] + (data.length > 40 ? "..." : "") puts " text : #{abbrev.inspect}" end
to_hash(pairs)
click to toggle source
# File lib/thinp_xml/listener.rb, line 6 def to_hash(pairs) r = Hash.new pairs.each do |p| r[p[0].intern] = p[1] end r end