API wrapper in ruby not taking arguments? -
i writing library interact elophant api , current wrapper current game infomation
looks this
require "httparty" class elophant include httparty base_uri 'api.elophant.com' def initialize(name, region) @options = {query: { summoner_name: name, region: region, key: env["elophant_api_key"] }} end def self.current_game httparty.get("/v2/#{region}/in_progress_game_info/#{summoner_name}?key=#{key}", @options) end def self.summoner_info httparty.get("/v2/#{region}/summoner/#{summoner_name}?key=#{key}", @options) end end
so can call
elophant = elophant.new elophant.current_game("summoner_name", "oce")
sending info rails view so
def index elophant = elophant.new @currentgame = elophant.current_game("summoner_name", "oce") end
except rails throws error
wrong number of arguments (0 2) base_uri 'api.elophant.com' def initialize(name, region) @options = {query: { summoner_name: name, region: region,
try using elpohant
class this:
elophant = elophant.new("summoner_name", "oce") elophant.current_game
you have defined elophant
have 2 arguments in initializer, i.e. summoner_name
, region
. passing these in call current_game
.
if in case, these parameters local method calls, , can change depending on method being invoked, may want bring parameters methods i.e. current_game
in case.
Comments
Post a Comment