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


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)


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

def api_url
  @api_url
end

#authString


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

def auth
  @auth
end

#user_agentString


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

def user_agent
  @user_agent
end