Class: Rascal::Docker::Volume::Named

Inherits:
Base
  • Object
show all
Defined in:
lib/rascal/docker/volume.rb

Instance Method Summary collapse

Methods included from IOHelper

#say, setup, #stderr, #stdin, #stdout

Constructor Details

#initialize(name, container_path) ⇒ Named

Returns a new instance of Named.



9
10
11
12
# File 'lib/rascal/docker/volume.rb', line 9

def initialize(name, container_path)
  @prefixed_name = "#{NAME_PREFIX}#{name}"
  @container_path = container_path
end

Instance Method Details

#cleanObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/rascal/docker/volume.rb', line 18

def clean
  if exists?
    say "Removing volume #{@prefixed_name}"
    Docker.interface.run(
      'volume',
      'rm',
      @prefixed_name,
    )
  end
end

#exists?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
# File 'lib/rascal/docker/volume.rb', line 29

def exists?
  Docker.interface.run(
    'volume',
    'ls',
    '--quiet',
    '--filter', "name=^#{@prefixed_name}$",
    output: :id,
  )
end

#to_paramObject



14
15
16
# File 'lib/rascal/docker/volume.rb', line 14

def to_param
  "#{@prefixed_name}:#{@container_path}"
end