Class: Decking::Image

Inherits:
Object
  • Object
show all
Extended by:
Helpers, Enumerable
Includes:
Helpers
Defined in:
lib/decking/images.rb

Constant Summary

Constants included from Helpers

Helpers::CONSOLE_LENGTH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

clear_progressline, run_with_progress, run_with_threads_multiplexed

Constructor Details

#initialize(name, params) ⇒ Image

Returns a new instance of Image.



35
36
37
38
# File 'lib/decking/images.rb', line 35

def initialize name, params
  @name   = name
  @config = params
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/decking/images.rb', line 40

def method_missing method, *args, &block
  if config.key? method
    config[method]
  else
    super
  end
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



33
34
35
# File 'lib/decking/images.rb', line 33

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



33
34
35
# File 'lib/decking/images.rb', line 33

def name
  @name
end

Class Method Details

.[](name) ⇒ Object



24
25
26
# File 'lib/decking/images.rb', line 24

def [](name)
  instances[name] ||= new(name, @images[name])
end

.add(params) ⇒ Object



19
20
21
22
# File 'lib/decking/images.rb', line 19

def add params
  images.update params.name => params
  self[params.name]
end

.each(&block) ⇒ Object



28
29
30
# File 'lib/decking/images.rb', line 28

def each &block
  @instances.each(&block)
end

.imagesObject

def delete_all ; map{|n, c| c.delete }; end def delete_all!; map{|n, c| c.delete! }; end



11
12
13
# File 'lib/decking/images.rb', line 11

def images
  @images ||= Hash.new
end

.instancesObject



15
16
17
# File 'lib/decking/images.rb', line 15

def instances
  @instances ||= Hash.new
end