Class: SMPTool::VirtualVolume::FileInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/smp_tool/virtual_volume/file_interface.rb

Overview

Interface to add/retrieve files to/from a volume.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename:, data:) ⇒ FileInterface

Returns a new instance of FileInterface.



11
12
13
14
# File 'lib/smp_tool/virtual_volume/file_interface.rb', line 11

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

Instance Attribute Details

#dataObject

Returns the value of attribute data.



9
10
11
# File 'lib/smp_tool/virtual_volume/file_interface.rb', line 9

def data
  @data
end

#filenameObject

Returns the value of attribute filename.



9
10
11
# File 'lib/smp_tool/virtual_volume/file_interface.rb', line 9

def filename
  @filename
end

Instance Method Details

#[](key) ⇒ Object

Hash-like interface to access keys in the [] syntax.



17
# File 'lib/smp_tool/virtual_volume/file_interface.rb', line 17

def [](key) = send(key)

#[]=(key, value) ⇒ Object

Hash-like interface to access keys in the []= syntax.



20
21
22
# File 'lib/smp_tool/virtual_volume/file_interface.rb', line 20

def []=(key, value)
  send("#{key}=", value)
end

#to_hObject

Return ‘self` as a hash.



25
26
27
28
29
30
# File 'lib/smp_tool/virtual_volume/file_interface.rb', line 25

def to_h
  {
    filename: @filename,
    data: @data
  }
end