Class: Docker::Event

Inherits:
Object
  • Object
show all
Extended by:
Error
Includes:
Error
Defined in:
lib/docker/event.rb

Overview

This class represents a Docker Image.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#fromObject

Returns the value of attribute from.



5
6
7
# File 'lib/docker/event.rb', line 5

def from
  @from
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/docker/event.rb', line 5

def id
  @id
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/docker/event.rb', line 5

def status
  @status
end

#timeObject

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_sObject



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