Class: Pubnub::Response
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#message ⇒ Object
(also: #msg)
readonly
Returns the value of attribute message.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
-
#timetoken ⇒ Object
readonly
Returns the value of attribute timetoken.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Simple compare to other object basing on string representation of response (see #to_s).
-
#initialize(options = {}) ⇒ Response
constructor
Creates Pubnub::Response object based on options hash.
Constructor Details
#initialize(options = {}) ⇒ Response
Creates Pubnub::Response object based on options hash
Sets @message, @channel, @timetoken, @status_code, :response attributes To properly init new response object it need :http, :response, :channel options While you pass :index option it will treat :response as array which size is greater than one In case you want create your custom error response, you have to pass :error_init option with true value and :message with your message
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pubnub/response.rb', line 19 def initialize( = {}) @path = [:path] @query = [:query] if [:error_init] @message = [:message] @response = [:message] @timetoken = 0 else if [:http].respond_to?(:body) && [:http].respond_to?(:code) && [:http].respond_to?(:message) && [:http].respond_to?(:headers) httparty = true else httparty = false end if httparty case [:operation] when 'publish' set_for_httparty() when 'subscribe' set_for_httparty() when 'presence' set_for_httparty() when 'history' set_for_httparty() when 'leave' set_for_httparty() when 'here_now' set_for_httparty() when 'time' set_for_httparty() end else # EM.http_request case [:operation] when 'publish' set_for_em_http_request() when 'subscribe' set_for_em_http_request() when 'presence' set_for_em_http_request() when 'history' set_for_em_http_request() when 'leave' set_for_em_http_request() when 'here_now' set_for_em_http_request() when 'time' set_for_em_http_request() end end end end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
2 3 4 |
# File 'lib/pubnub/response.rb', line 2 def channel @channel end |
#message ⇒ Object (readonly) Also known as: msg
Returns the value of attribute message.
2 3 4 |
# File 'lib/pubnub/response.rb', line 2 def @message end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/pubnub/response.rb', line 3 def path @path end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
3 4 5 |
# File 'lib/pubnub/response.rb', line 3 def query @query end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/pubnub/response.rb', line 3 def response @response end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
2 3 4 |
# File 'lib/pubnub/response.rb', line 2 def status_code @status_code end |
#timetoken ⇒ Object (readonly)
Returns the value of attribute timetoken.
2 3 4 |
# File 'lib/pubnub/response.rb', line 2 def timetoken @timetoken end |
Instance Method Details
#==(other) ⇒ Object
Simple compare to other object basing on string representation of response (see #to_s)
74 75 76 |
# File 'lib/pubnub/response.rb', line 74 def ==(other) @response == other.to_s end |