Class: SMPTool::VirtualVolume::DataEntry

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/smp_tool/virtual_volume/data_entry.rb

Overview

Volume data entry: permanent file or empty entry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header:, data:) ⇒ DataEntry

Returns a new instance of DataEntry.



16
17
18
19
# File 'lib/smp_tool/virtual_volume/data_entry.rb', line 16

def initialize(header:, data:)
  @header = header
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



14
15
16
# File 'lib/smp_tool/virtual_volume/data_entry.rb', line 14

def data
  @data
end

#headerObject (readonly)

Returns the value of attribute header.



14
15
16
# File 'lib/smp_tool/virtual_volume/data_entry.rb', line 14

def header
  @header
end

Instance Method Details

#cleanObject

Turn ‘self` into an empty entry.



39
40
41
42
43
44
# File 'lib/smp_tool/virtual_volume/data_entry.rb', line 39

def clean
  @header.clean
  @data = @data.gsub(/./m, PAD_CHR)

  self
end

#resize(new_size) ⇒ DataEntry

Resize data string to a new size.

Parameters:

  • new_size (Integer)

Returns:



28
29
30
31
32
33
34
# File 'lib/smp_tool/virtual_volume/data_entry.rb', line 28

def resize(new_size)
  @header.resize(new_size)

  @data = @data.slice(0, new_size).ljust(new_size, PAD_CHR)

  self
end