Class: Docker::Event
- Inherits:
-
Object
- Object
- Docker::Event
- Extended by:
- Error
- Includes:
- Error
- Defined in:
- lib/docker/event.rb
Overview
This class represents a Docker Event.
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#id ⇒ Object
Returns the value of attribute id.
-
#status ⇒ Object
Returns the value of attribute status.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
- .new_event(body, remaining, total) ⇒ Object
- .since(since, opts = {}, conn = Docker.connection, &block) ⇒ Object
- .stream(opts = {}, conn = Docker.connection, &block) ⇒ Object
Instance Method Summary collapse
-
#initialize(status, id, from, time) ⇒ Event
constructor
A new instance of Event.
- #to_s ⇒ Object
Constructor Details
#initialize(status, id, from, time) ⇒ Event
Returns a new instance of Event.
7 8 9 |
# File 'lib/docker/event.rb', line 7 def initialize(status, id, from, time) @status, @id, @from, @time = status, id, from, time end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
5 6 7 |
# File 'lib/docker/event.rb', line 5 def from @from end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/docker/event.rb', line 5 def id @id end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/docker/event.rb', line 5 def status @status end |
#time ⇒ Object
Returns the value of attribute time.
5 6 7 |
# File 'lib/docker/event.rb', line 5 def time @time end |
Class Method Details
.new_event(body, remaining, total) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/docker/event.rb', line 29 def new_event(body, remaining, total) return if body.nil? || body.empty? json = Docker::Util.parse_json(body) Docker::Event.new( json['status'], json['id'], json['from'], json['time'] ) end |
.since(since, opts = {}, conn = Docker.connection, &block) ⇒ Object
25 26 27 |
# File 'lib/docker/event.rb', line 25 def since(since, opts = {}, conn = Docker.connection, &block) stream(opts.merge(:since => since), conn, &block) end |
.stream(opts = {}, conn = Docker.connection, &block) ⇒ Object
19 20 21 22 23 |
# File 'lib/docker/event.rb', line 19 def stream(opts = {}, conn = Docker.connection, &block) conn.get('/events', opts, :response_block => lambda { |b, r, t| block.call(new_event(b, r, t)) }) end |
Instance Method Details
#to_s ⇒ Object
11 12 13 14 |
# File 'lib/docker/event.rb', line 11 def to_s "Docker::Event { :status => #{self.status}, :id => #{self.id}, "\ ":from => #{self.from}, :time => #{self.time} }" end |