class WeebSh::Client

Wrapper class that ties all modules together

Attributes

api_url[R]

@return [String] the URL being used for weeb.sh.

auth[R]

@return [String] the authorization used in weeb.sh.

auto_image[R]

@return [String] the korra class tied with the client.

image[R]

@return [Topc] the toph class tied with the client.

image_gen[R]

@return [String] the korra class tied with the client.

images[R]

@return [Topc] the toph class tied with the client.

korra[R]

@return [String] the korra class tied with the client.

rep[R]

@return [String] the shimakaze class tied with the client.

reputation[R]

@return [String] the shimakaze class tied with the client.

settings[R]

@return [String] the tama class tied with the client.

shimakaze[R]

@return [String] the shimakaze class tied with the client.

tama[R]

@return [String] the tama class tied with the client.

toph[R]

@return [Topc] the toph class tied with the client.

user_agent[R]

@return [String] the user agent used in weeb.sh.

Public Class Methods

new(auth, user_agent = nil, api_url: 'https://api.weeb.sh') click to toggle source

Groups all interfaces into one. @param auth [String] the authentication required to use weeb.sh. @param user_agent [String, Hash] the user agent to use with requests. @param api_url [String] the URL to use when using the weeb.sh API.

# 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

Public Instance Methods

api_url=(api_url) click to toggle source
# File lib/weeb/interfaces/client.rb, line 72
def api_url=(api_url)
  @api_url = api_url
  @toph.api_url = api_url
  @korra.api_url = api_url
  @shimakaze.api_url = api_url
  @tama.api_url = api_url
end
auth=(auth) click to toggle source
# File lib/weeb/interfaces/client.rb, line 64
def auth=(auth)
  @auth = auth
  @toph.auth = auth
  @korra.auth = auth
  @shimakaze.auth = auth
  @tama.auth = auth
end
inspect() click to toggle source
# File lib/weeb/interfaces/client.rb, line 80
def inspect
  "#<WeebSh::Client @api_url=#{@api_url.inspect} @user_agent=#{@user_agent.inspect}>"
end
user_agent=(user_agent) click to toggle source
# File lib/weeb/interfaces/client.rb, line 56
def user_agent=(user_agent)
  @user_agent = user_agent
  @toph.user_agent = user_agent
  @korra.user_agent = user_agent
  @shimakaze.user_agent = user_agent
  @tama.user_agent = user_agent
end