Class: Microsandbox::VolumeInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/microsandbox/volume.rb

Overview

A named persistent volume, from Microsandbox::Volume.create / Microsandbox::Volume.get / Microsandbox::Volume.list.

‘path` is populated when returned from Microsandbox::Volume.create; the storage stats (`kind`, `used_bytes`, …) are populated when returned from Microsandbox::Volume.get/Microsandbox::Volume.list.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ VolumeInfo

Returns a new instance of VolumeInfo.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/microsandbox/volume.rb', line 12

def initialize(data)
  @name = data["name"]
  @path = data["path"]
  @kind = data["kind"]
  @quota_mib = data["quota_mib"]
  @used_bytes = data["used_bytes"]
  @capacity_bytes = data["capacity_bytes"]
  @disk_format = data["disk_format"]
  @disk_fstype = data["disk_fstype"]
  @labels = data["labels"] || {}
  @created_at_ms = data["created_at_ms"]
end

Instance Attribute Details

#capacity_bytesObject (readonly)

Returns the value of attribute capacity_bytes.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def capacity_bytes
  @capacity_bytes
end

#disk_formatObject (readonly)

Returns the value of attribute disk_format.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def disk_format
  @disk_format
end

#disk_fstypeObject (readonly)

Returns the value of attribute disk_fstype.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def disk_fstype
  @disk_fstype
end

#labelsObject (readonly)

Returns the value of attribute labels.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def labels
  @labels
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def path
  @path
end

#quota_mibObject (readonly)

Returns the value of attribute quota_mib.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def quota_mib
  @quota_mib
end

#used_bytesObject (readonly)

Returns the value of attribute used_bytes.



9
10
11
# File 'lib/microsandbox/volume.rb', line 9

def used_bytes
  @used_bytes
end

Instance Method Details

#created_atTime?

Returns:

  • (Time, nil)


31
32
33
# File 'lib/microsandbox/volume.rb', line 31

def created_at
  @created_at_ms && Time.at(@created_at_ms / 1000.0)
end

#inspectObject



35
36
37
# File 'lib/microsandbox/volume.rb', line 35

def inspect
  "#<Microsandbox::VolumeInfo name=#{@name.inspect}#{@kind ? " kind=#{@kind}" : ""}>"
end

#kindSymbol?

Returns :directory or :disk.

Returns:

  • (Symbol, nil)

    :directory or :disk



26
27
28
# File 'lib/microsandbox/volume.rb', line 26

def kind
  @kind&.to_sym
end