Class: Pubnub::Envelope

Inherits:
Object show all
Defined in:
lib/pubnub/envelope.rb

Overview

Every message from server is formatted into easy to use Envelope object

Direct Known Subclasses

ErrorEnvelope

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Envelope) initialize(parameters)

Returns a new instance of Envelope



20
21
22
23
24
# File 'lib/pubnub/envelope.rb', line 20

def initialize(parameters)
  parameters.each do |parameter, value|
    instance_variable_set("@#{parameter}", value)
  end
end

Instance Attribute Details

- (Object) action

Returns the value of attribute action



7
8
9
# File 'lib/pubnub/envelope.rb', line 7

def action
  @action
end

- (Object) channel

Returns the value of attribute channel



6
7
8
# File 'lib/pubnub/envelope.rb', line 6

def channel
  @channel
end

- (Object) error

Returns the value of attribute error



7
8
9
# File 'lib/pubnub/envelope.rb', line 7

def error
  @error
end

- (Object) first

Returns the value of attribute first



5
6
7
# File 'lib/pubnub/envelope.rb', line 5

def first
  @first
end

- (Object) group

Returns the value of attribute group



8
9
10
# File 'lib/pubnub/envelope.rb', line 8

def group
  @group
end

- (Object) history_end

history specific



14
15
16
# File 'lib/pubnub/envelope.rb', line 14

def history_end
  @history_end
end

- (Object) history_start

history specific



14
15
16
# File 'lib/pubnub/envelope.rb', line 14

def history_start
  @history_start
end

- (Object) last

Returns the value of attribute last



5
6
7
# File 'lib/pubnub/envelope.rb', line 5

def last
  @last
end

- (Object) message Also known as: msg

Returns the value of attribute message



6
7
8
# File 'lib/pubnub/envelope.rb', line 6

def message
  @message
end

- (Object) object

Returns the value of attribute object



5
6
7
# File 'lib/pubnub/envelope.rb', line 5

def object
  @object
end

- (Object) parsed_response

Returns the value of attribute parsed_response



5
6
7
# File 'lib/pubnub/envelope.rb', line 5

def parsed_response
  @parsed_response
end

- (Object) payload

Returns the value of attribute payload



6
7
8
# File 'lib/pubnub/envelope.rb', line 6

def payload
  @payload
end

- (Object) response

Returns the value of attribute response



5
6
7
# File 'lib/pubnub/envelope.rb', line 5

def response
  @response
end

- (Object) response_message

Returns the value of attribute response_message



7
8
9
# File 'lib/pubnub/envelope.rb', line 7

def response_message
  @response_message
end

- (Object) service

Returns the value of attribute service



6
7
8
# File 'lib/pubnub/envelope.rb', line 6

def service
  @service
end

- (Object) status Also known as: status_code

Returns the value of attribute status



5
6
7
# File 'lib/pubnub/envelope.rb', line 5

def status
  @status
end

- (Object) timetoken

Returns the value of attribute timetoken



6
7
8
# File 'lib/pubnub/envelope.rb', line 6

def timetoken
  @timetoken
end

- (Object) timetoken_update

subscribe, presence specific



11
12
13
# File 'lib/pubnub/envelope.rb', line 11

def timetoken_update
  @timetoken_update
end

- (Object) uuid

Returns the value of attribute uuid



7
8
9
# File 'lib/pubnub/envelope.rb', line 7

def uuid
  @uuid
end

- (Object) uuids

Returns the value of attribute uuids



7
8
9
# File 'lib/pubnub/envelope.rb', line 7

def uuids
  @uuids
end

- (Object) wildcard_channel

Returns the value of attribute wildcard_channel



8
9
10
# File 'lib/pubnub/envelope.rb', line 8

def wildcard_channel
  @wildcard_channel
end

Instance Method Details

- (Boolean) error?

Returns:

  • (Boolean)


37
38
39
# File 'lib/pubnub/envelope.rb', line 37

def error?
  error ? true : false
end

- (Boolean) first?

Returns:

  • (Boolean)


45
46
47
# File 'lib/pubnub/envelope.rb', line 45

def first?
  first
end

- (Boolean) last?

Returns:

  • (Boolean)


41
42
43
# File 'lib/pubnub/envelope.rb', line 41

def last?
  last
end

- (Object) mark_as_timetoken



26
27
28
29
30
31
32
33
34
35
# File 'lib/pubnub/envelope.rb', line 26

def mark_as_timetoken
  if (@parsed_response[0].empty?) &&
     (@parsed_response[1].size == 17)
    @timetoken_update = true
  else
    @timetoken_update = false
  end
rescue
  @timetoken_update = false
end