Module: NekosLife::API
- Defined in:
- lib/nekos/api.rb
Overview
Main API functions
Constant Summary collapse
- BASE =
'https://nekos.life/api/v2'.freeze
Class Method Summary collapse
-
.get(endpoint) ⇒ Hash
Requests an endpoint.
-
.img(type) ⇒ Hash
Requests an image.
-
.request(type, *attributes) ⇒ Hash
Request an endpoint easily.
Class Method Details
.get(endpoint) ⇒ Hash
Requests an endpoint
33 34 35 36 37 38 |
# File 'lib/nekos/api.rb', line 33 def get(endpoint) request( :get, "#{BASE}/#{endpoint}" ) end |
.img(type) ⇒ Hash
Requests an image
23 24 25 26 27 28 |
# File 'lib/nekos/api.rb', line 23 def img(type) request( :get, "#{BASE}/img/#{type}" ) end |
.request(type, *attributes) ⇒ Hash
Request an endpoint easily
14 15 16 17 18 |
# File 'lib/nekos/api.rb', line 14 def request(type, *attributes) parse_json(RestClient.send(type, *attributes)) rescue RuntimeError => e raise e end |