calls now accept codeblocks - lets call this version 1.0.0
This commit is contained in:
@@ -23,7 +23,11 @@ class ChampionModule < SightstoneBaseModule
|
||||
data['champions'].each do |champ|
|
||||
champions << Champion.new(champ)
|
||||
end
|
||||
return champions
|
||||
if block_given?
|
||||
yield champions
|
||||
else
|
||||
return champions
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -13,7 +13,11 @@ class DatadragonModule < SightstoneBaseModule
|
||||
response = _get_api_response(uri)
|
||||
_parse_response(response) { |resp|
|
||||
data = JSON.parse(resp)
|
||||
return data['v']
|
||||
if block_given?
|
||||
yield data['v']
|
||||
else
|
||||
return data['v']
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -25,7 +25,12 @@ class GameModule < SightstoneBaseModule
|
||||
response = _get_api_response(uri)
|
||||
_parse_response(response) { |resp|
|
||||
data = JSON.parse(resp)
|
||||
return MatchHistory.new(data)
|
||||
history = MatchHistory.new(data)
|
||||
if block_given?
|
||||
yield history
|
||||
else
|
||||
return history
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -29,7 +29,11 @@ class LeagueModule < SightstoneBaseModule
|
||||
leagueKeys.each do |key|
|
||||
leagues << League.new(data[key])
|
||||
end
|
||||
return leagues
|
||||
if block_given?
|
||||
yield leagues
|
||||
else
|
||||
return leagues
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -31,7 +31,12 @@ class StatsModule < SightstoneBaseModule
|
||||
|
||||
_parse_response(response) { |resp|
|
||||
data = JSON.parse(resp)
|
||||
return PlayerStatsSummaryList.new(data)
|
||||
statList = PlayerStatsSummaryList.new(data)
|
||||
if block_given?
|
||||
yield statList
|
||||
else
|
||||
return statList
|
||||
end
|
||||
}
|
||||
|
||||
end
|
||||
@@ -57,7 +62,12 @@ class StatsModule < SightstoneBaseModule
|
||||
|
||||
_parse_response(response) { |resp|
|
||||
data = JSON.parse(resp)
|
||||
return RankedStats.new(data)
|
||||
stats = RankedStats.new(data)
|
||||
if block_given?
|
||||
yield stats
|
||||
else
|
||||
return stats
|
||||
end
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
@@ -26,7 +26,12 @@ class SummonerModule < SightstoneBaseModule
|
||||
response = _get_api_response(uri)
|
||||
_parse_response(response) { |resp|
|
||||
data = JSON.parse(resp)
|
||||
return Summoner.new(data)
|
||||
s = Summoner.new(data)
|
||||
if block_given?
|
||||
yield s
|
||||
else
|
||||
return s
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
@@ -46,7 +51,11 @@ class SummonerModule < SightstoneBaseModule
|
||||
names_array.each do |summoner|
|
||||
names_hash[summoner['id']] = summoner['name']
|
||||
end
|
||||
return names_hash
|
||||
if block_given?
|
||||
yield names_hash
|
||||
else
|
||||
return names_hash
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
@@ -65,7 +74,12 @@ class SummonerModule < SightstoneBaseModule
|
||||
response = _get_api_response(uri)
|
||||
_parse_response(response) { |resp|
|
||||
data = JSON.parse(resp)
|
||||
return RuneBook.new(data)
|
||||
book = RuneBook.new(data)
|
||||
if block_given?
|
||||
yield book
|
||||
else
|
||||
return book
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
@@ -84,7 +98,12 @@ class SummonerModule < SightstoneBaseModule
|
||||
response = _get_api_response(uri)
|
||||
_parse_response(response) { |resp|
|
||||
data = JSON.parse(resp)
|
||||
return MasteryBook.new(data)
|
||||
book = MasteryBook.new(data)
|
||||
if block_given?
|
||||
yield book
|
||||
else
|
||||
return book
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,7 +29,11 @@ class TeamModule < SightstoneBaseModule
|
||||
data.each do |team|
|
||||
teams << Team.new(team)
|
||||
end
|
||||
return teams
|
||||
if block_given?
|
||||
yield teams
|
||||
else
|
||||
return teams
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user