Class: Mastodon::Streaming::Client
- Defined in:
- lib/mastodon/streaming/client.rb
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.
-
#direct(options = {}) {|Mastodon::Conversation| ... } ⇒ Object
Returns conversations for a single user.
-
#hashtag(tag, options = {}) {|Mastodon::Status, Mastodon::Streaming::Events::StatusDelete| ... } ⇒ Object
Returns statuses that contain the specified hashtag.
-
#initialize(options = {}) ⇒ Mastodon::Streaming::Client
constructor
Initializes a new Client object.
-
#public(options = {}) {|Mastodon::Status, Mastodon::Streaming::Events::StatusDelete| ... } ⇒ Object
Returns all public statuses.
-
#stream(path, options = {}) {|Mastodon::Status, Mastodon::Notification, Mastodon::Streaming::DeletedStatus| ... } ⇒ Object
Calls an arbitrary streaming endpoint and returns the results.
-
#user(options = {}) {|Mastodon::Status, Mastodon::Notification, Mastodon::Streaming::Events::StatusDelete, Mastodon::Streaming::Events::FiltersChange| ... } ⇒ Object
Streams messages for a single user.
Methods inherited from Client
Constructor Details
#initialize(options = {}) ⇒ Mastodon::Streaming::Client
Initializes a new Client object
18 19 20 21 22 |
# File 'lib/mastodon/streaming/client.rb', line 18 def initialize( = {}) super [:using_ssl] ||= base_url =~ /^https/ @connection = Streaming::Connection.new() end |
Instance Attribute Details
#connection=(value) ⇒ Object (writeonly)
Sets the attribute connection
10 11 12 |
# File 'lib/mastodon/streaming/client.rb', line 10 def connection=(value) @connection = value end |
Instance Method Details
#before_request(&block) ⇒ Object
Set a Proc to be run when connection established.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/mastodon/streaming/client.rb', line 60 def before_request(&block) if block_given? @before_request = block self elsif instance_variable_defined?(:@before_request) @before_request else proc {} end end |
#direct(options = {}) {|Mastodon::Conversation| ... } ⇒ Object
Returns conversations for a single user
48 49 50 |
# File 'lib/mastodon/streaming/client.rb', line 48 def direct( = {}, &block) stream('direct', , &block) end |
#hashtag(tag, options = {}) {|Mastodon::Status, Mastodon::Streaming::Events::StatusDelete| ... } ⇒ Object
Returns statuses that contain the specified hashtag
34 35 36 |
# File 'lib/mastodon/streaming/client.rb', line 34 def hashtag(tag, = {}, &block) stream('hashtag', { tag: tag }.merge(), &block) end |
#public(options = {}) {|Mastodon::Status, Mastodon::Streaming::Events::StatusDelete| ... } ⇒ Object
Returns all public statuses
41 42 43 |
# File 'lib/mastodon/streaming/client.rb', line 41 def public( = {}, &block) stream('public', , &block) end |
#stream(path, options = {}) {|Mastodon::Status, Mastodon::Notification, Mastodon::Streaming::DeletedStatus| ... } ⇒ Object
Calls an arbitrary streaming endpoint and returns the results
55 56 57 |
# File 'lib/mastodon/streaming/client.rb', line 55 def stream(path, = {}, &block) request(:get, "/api/v1/streaming/#{path}", , &block) end |
#user(options = {}) {|Mastodon::Status, Mastodon::Notification, Mastodon::Streaming::Events::StatusDelete, Mastodon::Streaming::Events::FiltersChange| ... } ⇒ Object
Streams messages for a single user
27 28 29 |
# File 'lib/mastodon/streaming/client.rb', line 27 def user( = {}, &block) stream('user', , &block) end |