Class: Construi::IntermediateImage

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

Overview

An image that represents an intermediatae state of an image. Useful for performing operations where each opertion is performed on the result of the last.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image) ⇒ IntermediateImage

Returns a new instance of IntermediateImage.



119
120
121
122
# File 'lib/construi/image.rb', line 119

def initialize(image)
  @image = image
  @first = true
end

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image.



117
118
119
# File 'lib/construi/image.rb', line 117

def image
  @image
end

Class Method Details

.seed(image) ⇒ Object



149
150
151
# File 'lib/construi/image.rb', line 149

def self.seed(image)
  new image
end

Instance Method Details

#deleteObject



145
146
147
# File 'lib/construi/image.rb', line 145

def delete
  @image.delete unless @image.tagged?
end

#mapObject



128
129
130
# File 'lib/construi/image.rb', line 128

def map
  update(yield @image)
end

#reduce(iter) ⇒ Object



132
133
134
135
136
# File 'lib/construi/image.rb', line 132

def reduce(iter)
  iter.reduce(self) do |intermediate_image, item|
    intermediate_image.map { |i| yield i, item }
  end
end

#run(cmd, options = {}) ⇒ Object



124
125
126
# File 'lib/construi/image.rb', line 124

def run(cmd, options = {})
  map { |i| i.run cmd, options }
end

#update(image) ⇒ Object



138
139
140
141
142
143
# File 'lib/construi/image.rb', line 138

def update(image)
  delete unless @first
  @first = false
  @image = image
  self
end