Class: DC::Image

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, directory: name) ⇒ Image

Returns a new instance of Image.



75
76
77
78
79
# File 'lib/dc.rb', line 75

def initialize name, directory: name
  @name = name
  @directory = directory
  self.class[name] = self
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



81
82
83
# File 'lib/dc.rb', line 81

def name
  @name
end

Class Method Details

.[](name) ⇒ Object



66
67
68
# File 'lib/dc.rb', line 66

def [] name
  all[name]
end

.[]=(name, image) ⇒ Object



70
71
72
# File 'lib/dc.rb', line 70

def []= name, image
  all[name] = image
end

.allObject



62
63
64
# File 'lib/dc.rb', line 62

def all
  @all ||= {}
end

Instance Method Details

#buildObject



87
88
89
90
91
92
93
94
# File 'lib/dc.rb', line 87

def build
  build_parent_image_if_available
  image = Docker::Image.build_from_dir @directory do |json|
    puts JSON.parse json
  end
  image.tag repo: @name
  image
end

#exist?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/dc.rb', line 83

def exist?
  Docker::Image.exist? @name
end