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

#initialize(options) ⇒ Envelope

Returns a new instance of Envelope.



12
13
14
15
16
17
18
19
20
# File 'lib/pubnub/envelope.rb', line 12

def initialize(options)
  @id            = UUID.generate # internal usage only

  @event         = options[:event]
  @event_options = options[:event_options]
  @status        = options[:status]
  @result        = options[:result]
  @timetoken     = options[:timetoken]
end

Instance Attribute Details

#firstObject

Ruby specific



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

def first
  @first
end

#history_endObject

Returns the value of attribute history_end.



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

def history_end
  @history_end
end

#history_startObject

Returns the value of attribute history_start.



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

def history_start
  @history_start
end

#idObject

Ruby specific



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

def id
  @id
end

#lastObject

Ruby specific



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

def last
  @last
end

#resultObject

Pubnub Required



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

def result
  @result
end

#statusObject

Pubnub Required



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

def status
  @status
end

#timetokenObject

Pubnub Required



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

def timetoken
  @timetoken
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/pubnub/envelope.rb', line 26

def error?
  @status[:error]
end

#first?Boolean

:nocov:

Returns:

  • (Boolean)


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

def first?
  first
end

#last?Boolean

:nocov:

Returns:

  • (Boolean)


31
32
33
# File 'lib/pubnub/envelope.rb', line 31

def last?
  last
end

#repeat(client, changes = {}) ⇒ Object



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

def repeat(client, changes = {})
  client.send @event, @event_options.merge(changes)
end