calls now accept codeblocks - lets call this version 1.0.0

This commit is contained in:
danijoo
2014-01-01 19:59:06 +01:00
parent 466d0e8f66
commit dc6d037768
8 changed files with 62 additions and 12 deletions

View File

@@ -23,7 +23,11 @@ class ChampionModule < SightstoneBaseModule
data['champions'].each do |champ|
champions << Champion.new(champ)
end
if block_given?
yield champions
else
return champions
end
}
end
end

View File

@@ -13,7 +13,11 @@ class DatadragonModule < SightstoneBaseModule
response = _get_api_response(uri)
_parse_response(response) { |resp|
data = JSON.parse(resp)
if block_given?
yield data['v']
else
return data['v']
end
}
end

View File

@@ -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

View File

@@ -29,7 +29,11 @@ class LeagueModule < SightstoneBaseModule
leagueKeys.each do |key|
leagues << League.new(data[key])
end
if block_given?
yield leagues
else
return leagues
end
}
end

View File

@@ -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

View File

@@ -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
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

View File

@@ -29,7 +29,11 @@ class TeamModule < SightstoneBaseModule
data.each do |team|
teams << Team.new(team)
end
if block_given?
yield teams
else
return teams
end
}
end

View File

@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'sightstone'
s.version = '0.9.1'
s.version = '1.0.0'
s.date = '2014-01-01'
s.summary = 'Ruby wrapper for riots league of legends api'
s.description = s.summary