Class: ThinpXML::ParseDetail::Listener
- Inherits:
-
Object
- Object
- ThinpXML::ParseDetail::Listener
show all
- Includes:
- REXML::StreamListener, Base::ListenerUtils
- Defined in:
- lib/thinp_xml/thinp/parse.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#get_fields, #text, #to_hash
Constructor Details
19
20
21
|
# File 'lib/thinp_xml/thinp/parse.rb', line 19
def initialize
@metadata = Metadata.new(nil, Array.new)
end
|
Instance Attribute Details
Returns the value of attribute metadata.
17
18
19
|
# File 'lib/thinp_xml/thinp/parse.rb', line 17
def metadata
@metadata
end
|
Instance Method Details
#tag_end(tag) ⇒ Object
47
48
|
# File 'lib/thinp_xml/thinp/parse.rb', line 47
def tag_end(tag)
end
|
#tag_start(tag, args) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# 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
|