Sha256: 5fc663cb6d54314273f22f565d8df4cac478f15b1c3dba23b01937b714825a1c

Contents?: true

Size: 716 Bytes

Versions: 1

Compression:

Stored size: 716 Bytes

Contents

# encoding: utf-8
require 'ruby_ami/response'

module RubyAMI
  class Event < Response
    attr_reader :name, :receipt_time

    def initialize(name, headers = {})
      @receipt_time = DateTime.now
      super headers
      @name = name
    end

    # @return [DateTime, nil] the timestamp of the event, or nil if none is available
    def timestamp
      return unless headers['Timestamp']
      DateTime.strptime headers['Timestamp'], '%s'
    end

    # @return [DateTime] the best known timestamp for the event. Either its timestamp if specified, or its receipt time if not.
    def best_time
      timestamp || receipt_time
    end

    def inspect_attributes
      [:name] + super
    end
  end
end # RubyAMI

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_ami-2.2.0 lib/ruby_ami/event.rb