class ThinpXML::ParseDetail::Listener

Attributes

metadata[R]

Public Class Methods

new() click to toggle source
# File lib/thinp_xml/thinp/parse.rb, line 19
def initialize
  @metadata = Metadata.new(nil, Array.new)
end

Public Instance Methods

tag_end(tag) click to toggle source
# File lib/thinp_xml/thinp/parse.rb, line 47
def tag_end(tag)
end
tag_start(tag, args) click to toggle source
# File lib/thinp_xml/thinp/parse.rb, line 24
def tag_start(tag, args)
  attr = to_hash(args)

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

  when 'device'
    attr[:mappings] = Array.new
    @current_device = Device.new(*get_fields(attr, DEVICE_FIELDS))
    @metadata.devices << @current_device

  when 'single_mapping'
    @current_device.mappings << Mapping.new(attr[:origin_block].to_i, attr[:data_block].to_i, 1, attr[:time])

  when 'range_mapping'
    @current_device.mappings << Mapping.new(*get_fields(attr, MAPPING_FIELDS))

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