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 Event.

Defined Under Namespace

Classes: Actor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_attributes = {}) ⇒ Event

Returns a new instance of Event.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/docker/event.rb', line 52

def initialize(event_attributes = {})
  [:Type, :Action, :Actor, :time, :timeNano, :status, :from].each do |sym|
    value = event_attributes[sym]
    if value.nil?
      value = event_attributes[sym.to_s]
    end
    send("#{sym}=", value)
  end

  if @Actor.nil?
    value = event_attributes[:id]
    if value.nil?
      value = event_attributes['id']
    end
    self.Actor = Actor.new(ID: value)
  end
end

Instance Attribute Details

#ActionObject Also known as: action

Returns the value of attribute Action.



47
48
49
# File 'lib/docker/event.rb', line 47

def Action
  @Action
end

#ActorObject Also known as: actor

Returns the value of attribute Actor.



48
49
50
# File 'lib/docker/event.rb', line 48

def Actor
  @Actor
end

#fromObject

Deprecated interface



50
51
52
# File 'lib/docker/event.rb', line 50

def from
  @from
end

#statusObject

Deprecated interface



50
51
52
# File 'lib/docker/event.rb', line 50

def status
  @status
end

#timeObject

Returns the value of attribute time.



47
48
49
# File 'lib/docker/event.rb', line 47

def time
  @time
end

#timeNanoObject Also known as: time_nano

Returns the value of attribute timeNano.



47
48
49
# File 'lib/docker/event.rb', line 47

def timeNano
  @timeNano
end

#TypeObject Also known as: type

Returns the value of attribute Type.



47
48
49
# File 'lib/docker/event.rb', line 47

def Type
  @Type
end

Class Method Details

.new_event(body, remaining, total) ⇒ Object



40
41
42
43
44
# File 'lib/docker/event.rb', line 40

def new_event(body, remaining, total)
  return if body.nil? || body.empty?
  json = Docker::Util.parse_json(body)
  Docker::Event.new(json)
end

.since(since, opts = {}, conn = Docker.connection, &block) ⇒ Object



36
37
38
# File 'lib/docker/event.rb', line 36

def since(since, opts = {}, conn = Docker.connection, &block)
  stream(opts.merge(:since => since), conn, &block)
end

.stream(opts = {}, conn = Docker.connection, &block) ⇒ Object



30
31
32
33
34
# File 'lib/docker/event.rb', line 30

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

#IDObject Also known as: id



70
71
72
# File 'lib/docker/event.rb', line 70

def ID
  self.actor.ID
end

#to_sObject



89
90
91
92
93
94
95
# File 'lib/docker/event.rb', line 89

def to_s
  if type.nil? && action.nil?
    to_s_legacy
  else
    to_s_actor_style
  end
end