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.



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

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

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image.



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

def image
  @image
end

Class Method Details

.seed(image) ⇒ Object



155
156
157
# File 'lib/construi/image.rb', line 155

def self.seed(image)
  new image
end

Instance Method Details

#deleteObject



151
152
153
# File 'lib/construi/image.rb', line 151

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

#mapObject



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

def map
  update(yield @image)
end

#reduce(iter) ⇒ Object



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

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

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



130
131
132
# File 'lib/construi/image.rb', line 130

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

#update(image) ⇒ Object



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

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