Class: WeebSh::Client

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

Overview

Wrapper class that ties all modules together

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Groups all interfaces into one.


41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/weeb/interfaces/client.rb', line 41

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

  raise WeebSh::Err::BadAuth, 'Authorization is empty!' if auth.empty?
  puts '[WeebSh::Client] Your User Agent is empty. Please consider adding a user agent to help identify issues easier.' if user_agent.nil?
  puts '[WeebSh::Client] 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

  @toph = WeebSh::Toph.new(auth, user_agent, api_url: api_url, client: self)
  @korra = WeebSh::Korra.new(auth, user_agent, api_url: api_url, client: self)
  @shimakaze = WeebSh::Shimakaze.new(auth, user_agent, api_url: api_url, client: self)
  @tama = WeebSh::Tama.new(auth, user_agent, api_url: api_url, client: self)
end

Instance Attribute Details

#api_urlString


16
17
18
# File 'lib/weeb/interfaces/client.rb', line 16

def api_url
  @api_url
end

#authString


10
11
12
# File 'lib/weeb/interfaces/client.rb', line 10

def auth
  @auth
end

#korraString (readonly) Also known as: image_gen, auto_image


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

def korra
  @korra
end

#shimakazeString (readonly) Also known as: reputation, rep


29
30
31
# File 'lib/weeb/interfaces/client.rb', line 29

def shimakaze
  @shimakaze
end

#tamaString (readonly) Also known as: settings


34
35
36
# File 'lib/weeb/interfaces/client.rb', line 34

def tama
  @tama
end

#tophTopc (readonly) Also known as: image, images


19
20
21
# File 'lib/weeb/interfaces/client.rb', line 19

def toph
  @toph
end

#user_agentString


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

def user_agent
  @user_agent
end

Instance Method Details

#inspectObject


80
81
82
# File 'lib/weeb/interfaces/client.rb', line 80

def inspect
  "#<WeebSh::Client @api_url=#{@api_url.inspect} @user_agent=#{@user_agent.inspect}>"
end