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.



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

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.



43
44
45
# File 'lib/maimai_net/client.rb', line 43

def cookies
  @cookies
end

#passwordObject (readonly)

Returns the value of attribute password.



43
44
45
# File 'lib/maimai_net/client.rb', line 43

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



43
44
45
# File 'lib/maimai_net/client.rb', line 43

def username
  @username
end

Class Method Details

.inherited(cls) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/maimai_net/client.rb', line 48

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



63
64
65
66
# File 'lib/maimai_net/client.rb', line 63

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

.regionsObject



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

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