module NekosLife::API
Main API
functions
Constants
- BASE
Public Instance Methods
get(endpoint)
click to toggle source
Requests an endpoint @param endpoint [String] the endpoint @return [Hash] the response given in JSON
# File lib/nekos/api.rb, line 33 def get(endpoint) request( :get, "#{BASE}/#{endpoint}" ) end
img(type)
click to toggle source
Requests an image @param type [String] the image type @return [Hash] the response given in JSON
# File lib/nekos/api.rb, line 23 def img(type) request( :get, "#{BASE}/img/#{type}" ) end
parse_json(raw)
click to toggle source
@!visibility private
# File lib/nekos/api.rb, line 41 def parse_json(raw) JSON.parse(raw) rescue JSON::ParserError raw end
request(type, *attributes)
click to toggle source
Request an endpoint easily @return [Hash] the response given in JSON
# File lib/nekos/api.rb, line 14 def request(type, *attributes) parse_json(RestClient.send(type, *attributes)) rescue RuntimeError => e raise e end