Sha256: 62aad0c074ba8ed502523ea4b10eea52dd72aabdf8d02ce00e01bef335b77744

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

module DeviceCloud
  class PushNotification::Base
    attr_reader :id, :device_id, :value, :queued_at, :type
    
    def self.handle!(file_data)
      event = new(file_data)
      event.handle!
    end

    def initialize(file_data)
      @file_data = file_data
      @id = data["id"]
      @device_id = data["device_id"]
      @type = data["type"]
      @queued_at = data["queued_dt"]
      @value = data["value"]
    end

    def handle!
      raise NotImplementedError
    end

    def full_path
      return '' unless id.size > 0
      id['fdPath'] + id['fdName']
    end

    def mac_address
      return '' unless device_id.size > 0
      device_id.sub(/\Am:/, '').scan(/.{2}|.+/).join(':')
    end

    def data
      @file_data.data
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
device_cloud-0.0.3 lib/device_cloud/push_notification/base.rb