Class: MaimaiNet::Client::Base

Inherits:
Object
  • Object
show all
Extended by:
ConnectionProvider
Includes:
ModuleExt
Defined in:
lib/maimai_net/client.rb,
lib/maimai_net/client.rb

Direct Known Subclasses

AsiaRegion, JapanRegion

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ConnectionProvider

default_connection, default_connection=, new, register_connection

Constructor Details

#initialize(username = nil, password = nil) ⇒ Base

Returns a new instance of Base.



31
32
33
34
35
# File 'lib/maimai_net/client.rb', line 31

def initialize(username = nil, password = nil)
  @username = username
  @password = password
  @cookies  = HTTP::CookieJar.new
end

Instance Attribute Details

#cookiesObject (readonly)

Returns the value of attribute cookies.



37
38
39
# File 'lib/maimai_net/client.rb', line 37

def cookies
  @cookies
end

#passwordObject (readonly)

Returns the value of attribute password.



37
38
39
# File 'lib/maimai_net/client.rb', line 37

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



37
38
39
# File 'lib/maimai_net/client.rb', line 37

def username
  @username
end

Class Method Details

.inherited(cls) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/maimai_net/client.rb', line 42

def inherited(cls)
  super

  return unless self.singleton_class == method(__method__).owner
  @_subclasses ||= []
  @_subclasses << cls unless @_subclasses.include?(cls)

  cls.singleton_class.undef_method :regions
end

.region_infoObject



57
58
59
60
# File 'lib/maimai_net/client.rb', line 57

def region_info
  fail NotImplementedError, "this client is not associated with region information" if (@_properties.to_h rescue {}).empty?
  @_properties.dup
end

.regionsObject



52
53
54
55
# File 'lib/maimai_net/client.rb', line 52

def regions
  fail NoMethodError, "invalid call" unless self == method(__method__).owner
  @_subclasses.dup
end