Class: Ably::Rest::Presence
- Inherits:
-
Object
- Object
- Ably::Rest::Presence
- Includes:
- Modules::Conversions
- Defined in:
- lib/ably/rest/presence.rb
Instance Attribute Summary collapse
-
#channel ⇒ Ably::Rest::Channel
readonly
Channel this Presence object is associated with.
-
#client ⇒ Ably::Rest::Client
readonly
Client for this Presence object.
Instance Method Summary collapse
-
#get(options = {}) ⇒ Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>
Obtain the set of members currently present for a channel.
-
#history(options = {}) ⇒ Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>
Return the presence messages history for the channel.
-
#initialize(client, channel) ⇒ Presence
constructor
Initialize a new Presence object.
Constructor Details
#initialize(client, channel) ⇒ Presence
Initialize a new Presence object
18 19 20 21 |
# File 'lib/ably/rest/presence.rb', line 18 def initialize(client, channel) @client = client @channel = channel end |
Instance Attribute Details
#channel ⇒ Ably::Rest::Channel (readonly)
Channel this Presence object is associated with
12 13 14 |
# File 'lib/ably/rest/presence.rb', line 12 def channel @channel end |
#client ⇒ Ably::Rest::Client (readonly)
Client for this Presence object
8 9 10 |
# File 'lib/ably/rest/presence.rb', line 8 def client @client end |
Instance Method Details
#get(options = {}) ⇒ Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>
Obtain the set of members currently present for a channel
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ably/rest/presence.rb', line 30 def get( = {}) = = { :limit => 100 }.merge() = { coerce_into: 'Ably::Models::PresenceMessage', async_blocking_operations: .delete(:async_blocking_operations), } response = client.get(base_path, ) Ably::Models::PaginatedResult.new(response, base_path, client, ) do || .tap do || end end end |
#history(options = {}) ⇒ Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>
Return the presence messages history for the channel
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ably/rest/presence.rb', line 59 def history( = {}) url = "#{base_path}/history" = = { :direction => :backwards, :limit => 100 }.merge() [:start, :end].each { |option| [option] = as_since_epoch([option]) if .has_key?(option) } raise ArgumentError, ":end must be equal to or after :start" if [:start] && [:end] && ([:start] > [:end]) = { coerce_into: 'Ably::Models::PresenceMessage', async_blocking_operations: .delete(:async_blocking_operations), } response = client.get(url, ) Ably::Models::PaginatedResult.new(response, url, client, ) do || .tap do || end end end |