Class: OSwitch::Image
- Inherits:
-
Struct
- Object
- Struct
- OSwitch::Image
- Extended by:
- Enumerable
- Defined in:
- lib/oswitch.rb,
lib/oswitch.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
38 39 40 |
# File 'lib/oswitch.rb', line 38 def created @created end |
#id ⇒ Object
Returns the value of attribute id
38 39 40 |
# File 'lib/oswitch.rb', line 38 def id @id end |
#repository ⇒ Object
Returns the value of attribute repository
38 39 40 |
# File 'lib/oswitch.rb', line 38 def repository @repository end |
#size ⇒ Object
Returns the value of attribute size
38 39 40 |
# File 'lib/oswitch.rb', line 38 def size @size end |
#tag ⇒ Object
Returns the value of attribute tag
38 39 40 |
# File 'lib/oswitch.rb', line 38 def tag @tag end |
Class Method Details
.all ⇒ Object
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
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 |