class ThinpXML::Builder
Attributes
block_size[RW]
nr_mappings[RW]
nr_thins[RW]
uuid[RW]
Public Class Methods
new()
click to toggle source
# File lib/thinp_xml/thinp/builder.rb, line 9 def initialize @uuid = '' @nr_thins = 0 @nr_mappings = 0 @block_size = 128 end
Public Instance Methods
generate()
click to toggle source
# File lib/thinp_xml/thinp/builder.rb, line 16 def generate nr_thins = @nr_thins.to_i mapping_counts = (0..nr_thins - 1).map {|n| @nr_mappings.to_i} nr_data_blocks = mapping_counts.inject(0) {|n, tot| n + tot} superblock = Superblock.new(@uuid, 0, 1, 0, 2, @block_size, nr_data_blocks) devices = Array.new offset = 0 0.upto(nr_thins - 1) do |dev| mappings = Array.new nr_mappings = mapping_counts[dev] if nr_mappings > 0 mappings << Mapping.new(0, offset, nr_mappings, 1) offset += nr_mappings end devices << Device.new(dev, nr_mappings, 0, 0, 0, mappings) end Metadata.new(superblock, devices) end