Class: OSwitch::Image
- Inherits:
-
Struct
- Object
- Struct
- OSwitch::Image
- Extended by:
- Enumerable
- Defined in:
- lib/oswitch/image.rb,
lib/oswitch/image.rb
Overview
Captures a docker image’s metadata.
Instance Attribute Summary collapse
-
#created ⇒ Object
Returns the value of attribute created.
-
#id ⇒ Object
Returns the value of attribute id.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#size ⇒ Object
Returns the value of attribute size.
-
#tag ⇒ Object
Returns the value of attribute tag.
Class Method Summary collapse
Instance Attribute Details
#created ⇒ Object
Returns the value of attribute created
3 4 5 |
# File 'lib/oswitch/image.rb', line 3 def created @created end |
#id ⇒ Object
Returns the value of attribute id
3 4 5 |
# File 'lib/oswitch/image.rb', line 3 def id @id end |
#repository ⇒ Object
Returns the value of attribute repository
3 4 5 |
# File 'lib/oswitch/image.rb', line 3 def repository @repository end |
#size ⇒ Object
Returns the value of attribute size
3 4 5 |
# File 'lib/oswitch/image.rb', line 3 def size @size end |
#tag ⇒ Object
Returns the value of attribute tag
3 4 5 |
# File 'lib/oswitch/image.rb', line 3 def tag @tag end |
Class Method Details
.all ⇒ Object
12 13 14 15 |
# File 'lib/oswitch/image.rb', line 12 def all `docker images`.split("\n").drop(1). map{|l| Image.new(*l.split(/\s{2,}/))} end |
.each(&block) ⇒ Object
17 18 19 |
# File 'lib/oswitch/image.rb', line 17 def each(&block) all.each(&block) end |
.exists?(imgname) ⇒ Boolean
28 29 30 |
# File 'lib/oswitch/image.rb', line 28 def exists?(imgname) !!get(imgname) end |
.get(imgname) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/oswitch/image.rb', line 21 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 |