Class: DC::Group

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, directory:) ⇒ Group

Returns a new instance of Group.



86
87
88
89
90
91
# File 'lib/dc.rb', line 86

def initialize hash, directory:
  @hash = hash
  @images = hash.keys.map do |name|
    Image.new name, directory: "#{directory}/#{name}"
  end
end

Instance Attribute Details

#imagesObject (readonly)

Returns the value of attribute images.



93
94
95
# File 'lib/dc.rb', line 93

def images
  @images
end

Instance Method Details

#build_missing_imagesObject



99
100
101
102
103
# File 'lib/dc.rb', line 99

def build_missing_images
  @images.each do |image|
    image.build unless image.exist?
  end
end

#containersObject



95
96
97
# File 'lib/dc.rb', line 95

def containers
  @containers ||= create_containers
end

#destroyObject



111
112
113
# File 'lib/dc.rb', line 111

def destroy
  containers.each &:destroy
end

#startObject



105
106
107
108
109
# File 'lib/dc.rb', line 105

def start
  network = Network.new
  containers.each { |container| network.connect container.id }
  containers.each &:start
end