Class: OSwitch::Image

Inherits:
Struct
  • Object
show all
Extended by:
Enumerable
Defined in:
lib/oswitch.rb,
lib/oswitch.rb

Overview

Captures a docker image’s metadata.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#createdObject

Returns the value of attribute created

Returns:

  • (Object)

    the current value of created



38
39
40
# File 'lib/oswitch.rb', line 38

def created
  @created
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



38
39
40
# File 'lib/oswitch.rb', line 38

def id
  @id
end

#repositoryObject

Returns the value of attribute repository

Returns:

  • (Object)

    the current value of repository



38
39
40
# File 'lib/oswitch.rb', line 38

def repository
  @repository
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



38
39
40
# File 'lib/oswitch.rb', line 38

def size
  @size
end

#tagObject

Returns the value of attribute tag

Returns:

  • (Object)

    the current value of tag



38
39
40
# File 'lib/oswitch.rb', line 38

def tag
  @tag
end

Class Method Details

.allObject



47
48
49
50
# File 'lib/oswitch.rb', line 47

def all
  `docker images`.split("\n").drop(1).
    map{|l| Image.new(*l.split(/\s{2,}/))}
end

.each(&block) ⇒ Object



52
53
54
# File 'lib/oswitch.rb', line 52

def each(&block)
  all.each(&block)
end

.exists?(imgname) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/oswitch.rb', line 63

def exists?(imgname)
  !!get(imgname)
end

.get(imgname) ⇒ Object



56
57
58
59
60
61
# File 'lib/oswitch.rb', line 56

def get(imgname)
  repository, tag = imgname.split(':')
  return if not repository or repository.empty?
  tag = 'latest' if not tag or tag.empty?
  find {|img| img.repository == repository and img.tag == tag}
end