Class: WeebSh::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/weeb/data.rb

Overview

Represents a generic interface

Direct Known Subclasses

Korra, Shimakaze, Tama, Toph

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth, user_agent = nil, api_url: 'https://api.weeb.sh', client: nil) ⇒ Interface

Returns a new instance of Interface.

Parameters:

  • auth (String)

    the authentication required to use weeb.sh.

  • user_agent (String, Hash) (defaults to: nil)

    the user agent to use on endpoints.

  • api_url (String) (defaults to: 'https://api.weeb.sh')

    the URL to use when using the weeb.sh API.

  • client (Client) (defaults to: nil)

    the client this is tied to.

Raises:


33
34
35
36
37
38
39
40
41
42
43
# File 'lib/weeb/data.rb', line 33

def initialize(auth, user_agent = nil, api_url: 'https://api.weeb.sh', client: nil)
  @user_agent = WeebSh::API.format_user_agent(user_agent)
  @auth = auth
  @api_url = api_url
  @client = client

  return if client
  raise WeebSh::Err::BadAuth, 'Authorization is empty!' if auth.empty?
  puts "[#{self.class.name}] Your User Agent is empty. Please consider adding a user agent to help identify issues easier." if user_agent.nil?
  puts "[#{self.class.name}] Your User Agent is not ideal. Please consider adding a user agent to help identify issues easier." if !user_agent.nil? && user_agent.split('/').count < 2
end

Instance Attribute Details

#api_urlString (readonly)

Returns the URL being used for weeb.sh.

Returns:

  • (String)

    the URL being used for weeb.sh.


27
28
29
# File 'lib/weeb/data.rb', line 27

def api_url
  @api_url
end

#authString

Returns the authorization used in weeb.sh.

Returns:

  • (String)

    the authorization used in weeb.sh.


21
22
23
# File 'lib/weeb/data.rb', line 21

def auth
  @auth
end

#user_agentString

Returns the user agent used in weeb.sh.

Returns:

  • (String)

    the user agent used in weeb.sh.


24
25
26
# File 'lib/weeb/data.rb', line 24

def user_agent
  @user_agent
end