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:

  • token (String)

    the token 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.

Raises:


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

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.


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

def api_url
  @api_url
end

#authString

Returns the authorization used in weeb.sh.

Returns:

  • (String)

    the authorization used in weeb.sh.


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

def auth
  @auth
end

#user_agentString

Returns the user agent used in weeb.sh.

Returns:

  • (String)

    the user agent used in weeb.sh.


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

def user_agent
  @user_agent
end

Instance Method Details

#inspectObject


43
44
45
# File 'lib/weeb/data.rb', line 43

def inspect
  "#<#{self.class.name} @api_url=#{@api_url.inspect} @user_agent=#{@user_agent.inspect}>"
end