Class: Mastodon::Streaming::Client
- Defined in:
- lib/mastodon/streaming/client.rb
Overview
Streaming client class, to handle all streaming purposes.
Constant Summary
Constants inherited from Client
Instance Attribute Summary collapse
-
#connection ⇒ Object
writeonly
Sets the attribute connection.
Attributes inherited from Client
#base_url, #bearer_token, #timeout
Instance Method Summary collapse
-
#before_request(&block) ⇒ Object
Set a Proc to be run when connection established.
-
#firehose(options = {}) {|Mastodon::Status, Mastodon::Notification, | ... } ⇒ Object
Returns all public statuses.
-
#hashtag(tag, options = {}) {|Mastodon::Status, Mastodon::Notification, | ... } ⇒ Object
Returns statuses that contain the specified hashtag.
-
#initialize(options = {}) ⇒ Mastodon::Streaming::Client
constructor
Initializes a new Client object.
-
#stream(path, options = {}) {|Mastodon::Status, Mastodon::Notification, | ... } ⇒ Object
Calls an arbitrary streaming endpoint and returns the results Mastodon::Streaming::DeletedStatus] A stream of Mastodon objects.
-
#user(options = {}) {|Mastodon::Status, Mastodon::Notification, | ... } ⇒ Object
Streams messages for a single user.
Methods inherited from Client
Constructor Details
#initialize(options = {}) ⇒ Mastodon::Streaming::Client
Initializes a new Client object
24 25 26 27 28 |
# File 'lib/mastodon/streaming/client.rb', line 24 def initialize( = {}) super [:using_ssl] ||= base_url =~ /^https/ @connection = Streaming::Connection.new() end |
Instance Attribute Details
#connection=(value) ⇒ Object (writeonly)
Sets the attribute connection
14 15 16 |
# File 'lib/mastodon/streaming/client.rb', line 14 def connection=(value) @connection = value end |
Instance Method Details
#before_request(&block) ⇒ Object
Set a Proc to be run when connection established.
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/mastodon/streaming/client.rb', line 64 def before_request(&block) if block_given? @before_request = block self elsif instance_variable_defined?(:@before_request) @before_request else proc {} end end |
#firehose(options = {}) {|Mastodon::Status, Mastodon::Notification, | ... } ⇒ Object
Returns all public statuses
Mastodon::Streaming::DeletedStatus] A stream of Mastodon objects.
51 52 53 |
# File 'lib/mastodon/streaming/client.rb', line 51 def firehose( = {}, &block) stream('public', , &block) end |
#hashtag(tag, options = {}) {|Mastodon::Status, Mastodon::Notification, | ... } ⇒ Object
Returns statuses that contain the specified hashtag
Mastodon::Streaming::DeletedStatus] A stream of Mastodon objects.
42 43 44 45 |
# File 'lib/mastodon/streaming/client.rb', line 42 def hashtag(tag, = {}, &block) ['tag'] = tag stream('hashtag', , &block) end |
#stream(path, options = {}) {|Mastodon::Status, Mastodon::Notification, | ... } ⇒ Object
Calls an arbitrary streaming endpoint and returns the results Mastodon::Streaming::DeletedStatus] A stream of Mastodon objects.
59 60 61 |
# File 'lib/mastodon/streaming/client.rb', line 59 def stream(path, = {}, &block) request(:get, "/api/v1/streaming/#{path}", , &block) end |
#user(options = {}) {|Mastodon::Status, Mastodon::Notification, | ... } ⇒ Object
Streams messages for a single user
Mastodon::Streaming::DeletedStatus] A stream of Mastodon objects.
34 35 36 |
# File 'lib/mastodon/streaming/client.rb', line 34 def user( = {}, &block) stream('user', , &block) end |