class CacheXML::CacheParseDetail::Listener

Attributes

metadata[R]

Public Class Methods

new() click to toggle source
# File lib/thinp_xml/cache/parse.rb, line 17
def initialize
  @metadata = Metadata.new(nil, [], [])
  @in_mappings = false
  @in_hints = false
end

Public Instance Methods

tag_end(tag) click to toggle source
# File lib/thinp_xml/cache/parse.rb, line 51
def tag_end(tag)
  case tag
  when 'mappings'
    @in_mappings = false

  when 'hints'
    @in_hints = false
  end
end
tag_start(tag, args) click to toggle source
# File lib/thinp_xml/cache/parse.rb, line 23
def tag_start(tag, args)
  attr = to_hash(args)

  case tag
  when 'superblock'
    @metadata.superblock = Superblock.new(*get_fields(attr, SUPERBLOCK_FIELDS))

  when 'mappings'
    @in_mappings = true

  when 'mapping'
    raise "not in mappings section" unless @in_mappings
    m = Mapping.new(*get_fields(attr, MAPPING_FIELDS))
    @metadata.mappings << m

  when 'hints'
    @in_hints = true

  when 'hint'
    raise "not in hints section" unless @in_hints
    h = Hint.new(*get_fields(attr, HINT_FIELDS))
    @metadata.hints << h

  else
    raise "unhandled tag '#{tag} #{attr.map {|x| x.inspect}.join(' ')}'"
  end
end