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



20
21
22
23
24
# File 'lib/mastodon/client.rb', line 20

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.



13
14
15
# File 'lib/mastodon/client.rb', line 13

def base_url
  @base_url
end

#bearer_tokenObject (readonly)

Returns the value of attribute bearer_token.



13
14
15
# File 'lib/mastodon/client.rb', line 13

def bearer_token
  @bearer_token
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



13
14
15
# File 'lib/mastodon/client.rb', line 13

def timeout
  @timeout
end

Instance Method Details

#user_agentString

User agent of the client

Returns:

  • (String)


28
29
30
# File 'lib/mastodon/client.rb', line 28

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