Sha256: 2b8638bb4325a0a6af3e11bc22730d13d7c86a2cd51131ad549bd9889564cd92

Contents?: true

Size: 732 Bytes

Versions: 4

Compression:

Stored size: 732 Bytes

Contents

# encoding: utf-8
require 'time'

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

4 entries across 4 versions & 1 rubygems

Version Path
ruby_ami-3.0.0 lib/ruby_ami/event.rb
ruby_ami-2.4.0 lib/ruby_ami/event.rb
ruby_ami-2.3.0 lib/ruby_ami/event.rb
ruby_ami-2.2.1 lib/ruby_ami/event.rb