Sha256: 49816583978fda826ff52083512643bd78a335f74709810122f9281f289ab4f6

Contents?: true

Size: 465 Bytes

Versions: 10

Compression:

Stored size: 465 Bytes

Contents

require_relative 'invalid_format_error'

module Grocer
  class FailedDeliveryAttempt
    LENGTH = 38

    attr_accessor :timestamp, :device_token

    def initialize(binary_tuple)
      # N   =>  4 byte timestamp
      # n   =>  2 byte token_length
      # H64 => 32 byte device_token
      seconds, _, @device_token = binary_tuple.unpack('NnH64')
      raise InvalidFormatError unless seconds && @device_token
      @timestamp = Time.at(seconds)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
grocer-0.0.10 lib/grocer/failed_delivery_attempt.rb
grocer-0.0.9 lib/grocer/failed_delivery_attempt.rb
grocer-0.0.8 lib/grocer/failed_delivery_attempt.rb
grocer-0.0.7 lib/grocer/failed_delivery_attempt.rb
grocer-0.0.6 lib/grocer/failed_delivery_attempt.rb
grocer-0.0.5 lib/grocer/failed_delivery_attempt.rb
grocer-0.0.4 lib/grocer/failed_delivery_attempt.rb
grocer-0.0.3 lib/grocer/failed_delivery_attempt.rb
grocer-0.0.2 lib/grocer/failed_delivery_attempt.rb
grocer-0.0.1 lib/grocer/failed_delivery_attempt.rb