Sha256: 1f169bc3b17f5e17fac7c722e33252985fdf0ec58c62b525ab1184d516e23165

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module OwskiLog
  module Status
    OK = 'OK'
    ERROR = 'ERROR'
  end

  class Event
    attr_accessor :key, :description,
                  :status, :cause,
                  :parent, :start_time,
                  :end_time, :sub_events

    def initialize(key, description,
                   status: nil, cause: nil,
                   parent: nil, start_time: Time.now.utc,
                   end_time: nil, sub_events: [])
      @key = key
      @description = description
      @status = status
      @cause = cause
      @parent = parent
      @start_time = start_time
      @end_time = end_time
      @sub_events = sub_events
    end

    def finish(status, cause: nil)
      @end_time = Time.now.utc
      @status = status
      @cause = cause
      self
    end

    def is_finished?
      @end_time && @status
    end

    def to_json(*a)
      {
          key: @key,
          description: @description,
          status: @status,
          start_time: @start_time,
          end_time: @end_time,
          sub_events: @sub_events
      }.to_json(*a)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
owskilog-0.2.0 lib/owskilog/event.rb