Class: CQHTTP::API

Inherits:
Object
  • Object
show all
Defined in:
lib/CQHTTP/api.rb

Overview

All API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host: 'http://localhost:5700', way: :json) ⇒ API

init

host: String: API address, like ‘localhost:5700’ type: Symbol or String, ‘get’, ‘form’ or ‘json;



10
11
12
13
14
15
# File 'lib/CQHTTP/api.rb', line 10

def initialize(host: 'http://localhost:5700', way: :json)
  @func_list = {}
  gen
  @func_list.freeze
  @network = CQHTTP::Network.gen way, host
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *user_args) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/CQHTTP/api.rb', line 21

def method_missing(name, *user_args)
  return super unless respond_to_missing? name

  args = gen_args name, user_args
  args.freeze
  return super if args.nil?
  return super if args.value? nil
  call_network name, args
end

Instance Attribute Details

#func_listObject (readonly)

Returns the value of attribute func_list.



4
5
6
# File 'lib/CQHTTP/api.rb', line 4

def func_list
  @func_list
end

Instance Method Details

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/CQHTTP/api.rb', line 17

def respond_to_missing?(method, include_private = false)
  @func_list.include?(method) || super
end