Class: Mastodon::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mastodon/client.rb

Direct Known Subclasses

REST::Client, Streaming::Client

Constant Summary collapse

DEFAULT_TIMEOUT =
{
  connect: 2,
  read: 5,
  write: 20,
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :base_url (String)

    URL of the instance you want to connect to

  • :bearer_token (String)

    OAuth access token for your authenticated user



16
17
18
19
20
# File 'lib/mastodon/client.rb', line 16

def initialize(options = {})
  @base_url     = options[:base_url]
  @bearer_token = options[:bearer_token]
  @timeout      = DEFAULT_TIMEOUT.merge(options[:timeout] || {})
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



11
12
13
# File 'lib/mastodon/client.rb', line 11

def base_url
  @base_url
end

#bearer_tokenObject (readonly)

Returns the value of attribute bearer_token.



11
12
13
# File 'lib/mastodon/client.rb', line 11

def bearer_token
  @bearer_token
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



11
12
13
# File 'lib/mastodon/client.rb', line 11

def timeout
  @timeout
end

Instance Method Details

#user_agentString

User agent of the client

Returns:

  • (String)


24
25
26
# File 'lib/mastodon/client.rb', line 24

def user_agent
  @user_agent ||= "MastodonRubyGem/#{Mastodon::Version}"
end