Class: ThinpXML::ParseDetail::Listener
- Inherits:
-
Object
- Object
- ThinpXML::ParseDetail::Listener
- Includes:
- REXML::StreamListener, Base::ListenerUtils
- Defined in:
- lib/thinp_xml/thinp/parse.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#initialize ⇒ Listener
constructor
A new instance of Listener.
- #tag_end(tag) ⇒ Object
- #tag_start(tag, args) ⇒ Object
Methods included from Base::ListenerUtils
Constructor Details
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
17 18 19 |
# File 'lib/thinp_xml/thinp/parse.rb', line 17 def @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 |