Class: Construi::IntermediateImage
- Inherits:
-
Object
- Object
- Construi::IntermediateImage
- 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
-
#image ⇒ Object
readonly
Returns the value of attribute image.
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(image) ⇒ IntermediateImage
constructor
A new instance of IntermediateImage.
- #map ⇒ Object
- #reduce(iter) ⇒ Object
- #run(cmd, options = {}) ⇒ Object
- #update(image) ⇒ Object
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
#image ⇒ Object (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
#delete ⇒ Object
145 146 147 |
# File 'lib/construi/image.rb', line 145 def delete @image.delete unless @image.tagged? end |
#map ⇒ Object
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, = {}) map { |i| i.run cmd, } 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 |