class Syncano::Packets::Base

Base class for representing packets used in communication with the Sync Server

Attributes

object[RW]
timestamp[RW]

Public Class Methods

instantize_packet(data) click to toggle source

Proxy method for creating instance of proper subclass @param [Hash] data @return [Syncano::Packets::Base]

# File lib/syncano/packets/base.rb, line 19
def self.instantize_packet(data)
  mapping = {
    auth: ::Syncano::Packets::Auth,
    call: ::Syncano::Packets::Call,
    callresponse: ::Syncano::Packets::CallResponse,
    error: ::Syncano::Packets::Error,
    message: ::Syncano::Packets::Message,
    new: ::Syncano::Packets::Notification,
    change: ::Syncano::Packets::Notification,
    delete: ::Syncano::Packets::Notification,
    ping: ::Syncano::Packets::Ping
  }

  mapping[data[:type].to_sym].new(data)
end
new(attributes) click to toggle source

Constructor for Syncano::Packets::Base object @param [Hash] attributes

Calls superclass method
# File lib/syncano/packets/base.rb, line 10
def initialize(attributes)
  super()
  self.timestamp = attributes[:timestamp]
  self.object = attributes[:object]
end

Public Instance Methods

auth?() click to toggle source

Returns true if is an auth packet @return [TrueClass, FalseClass]

# File lib/syncano/packets/base.rb, line 61
def auth?
  false
end
call_response?() click to toggle source

Returns true if is a call response packet @return [TrueClass, FalseClass]

# File lib/syncano/packets/base.rb, line 49
def call_response?
  false
end
message?() click to toggle source

Returns true if is a message packet @return [TrueClass, FalseClass]

# File lib/syncano/packets/base.rb, line 55
def message?
  false
end
notification?() click to toggle source

Returns true if is a notification packet @return [TrueClass, FalseClass]

# File lib/syncano/packets/base.rb, line 37
def notification?
  false
end
ping?() click to toggle source

Returns true if is a ping packet @return [TrueClass, FalseClass]

# File lib/syncano/packets/base.rb, line 43
def ping?
  false
end