Module: SMPTool::VirtualVolume::Utils::ConverterFromVolumeIO

Defined in:
lib/smp_tool/virtual_volume/utils/converter_from_volume_io.rb

Overview

Converts volume IO to the virtual volume.

Class Method Summary collapse

Class Method Details

.read_io(io) ⇒ Object



57
58
59
60
61
# File 'lib/smp_tool/virtual_volume/utils/converter_from_volume_io.rb', line 57

def self.read_io(io)
  read_volume_io(
    SMPTool::VolumeIO::VolumeIO.read(io)
  )
end

.read_volume_io(volume_io) ⇒ Object

Raises:

  • (ArgumentError)


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/smp_tool/virtual_volume/utils/converter_from_volume_io.rb', line 63

def self.read_volume_io(volume_io)
  entries = _read_entries(volume_io)
  data = volume_io.data.to_ary

  raise ArgumentError, "entries => data lengths mismatch" unless entries.length == data.length

  volume_params = _build_volume_params(volume_io)

  VirtualVolume::Volume.new(
    bootloader: volume_io.bootloader.bytes.to_ary,
    home_block: volume_io.home_block.bytes.to_ary,
    volume_params: volume_params,
    volume_data: _volume_data(entries, data, volume_params.extra_word)
  )
end