Sha256: 166ffff531d2f513475b495e52ce07d042bc8b3c59ce6724a2f5cbe81b30cf83

Contents?: true

Size: 1001 Bytes

Versions: 44

Compression:

Stored size: 1001 Bytes

Contents

# This class represents a Docker Image.
class Docker::Event
  include Docker::Error

  attr_accessor :status, :id, :from, :time

  def initialize(status, id, from, time)
    @status, @id, @from, @time = status, id, from, time
  end

  def to_s
    "Docker::Event { :status => #{self.status}, :id => #{self.id}, "\
      ":from => #{self.from}, :time => #{self.time} }"
  end

  class << self
    include Docker::Error

    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

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

    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
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
docker-api-1.7.4 lib/docker/event.rb
docker-api-1.7.3 lib/docker/event.rb
docker-api-1.7.2 lib/docker/event.rb
docker-api-1.7.0 lib/docker/event.rb