sightstone 1.4.4 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,76 +1,76 @@
1
- module Sightstone
2
- # match history of a summoner
3
- # @attr [Fixnum] summonerId ID of the summoner
4
- # @attr [Array<HistoryGame>] games unsorted list of recently played games
5
- class MatchHistory
6
- attr_accessor :games, :summonerId
7
-
8
- def initialize(data)
9
- @summonerId = data['summonerId']
10
- @games = []
11
- data['games'].each do |game|
12
- games << HistoryGame.new(game)
13
- end
14
- end
15
- end
16
-
17
- # A played game
18
- # @attr [Fixnum] championId ID of the played champ of requested summoner
19
- # @attr [Fixnum] createDate UNIX timestamp of creation date of the games
20
- # @attr [Array<Player>] fellowPlayers a list of all players of the game
21
- # @attr [Fixnum] gameId ID of the game
22
- # @attr [String] gameMode mode of the game
23
- # @attr [String] gameType type of the game
24
- # @attr [Boolean] invalid Invalid flag #TODO what is this?
25
- # @attr [Fixnum] level level of the requested summoner
26
- # @attr [Fixnum] mapId ID of the played map
27
- # @attr [Fixnum] spell1 selected summoner spell no 1
28
- # @attr [Fixnum] spell2 selected summoner spell no 2
29
- # @attr [String] subtype subtype
30
- # @attr [Fixnum] teamId ID of the team if there is a team associated to the game
31
- # @attr [Hash<String, Fixnum, Boolean>] statistics statistics of the game as a Hash: name -> value
32
- class HistoryGame
33
- attr_accessor :championId, :createDate, :fellowPlayers, :gameId, :gameMode, :gameType, :invalid, :level, :mapId, :spell1, :spell2, :statistics, :subType, :teamId
34
-
35
- def initialize(data)
36
- @championId=data['championId']
37
- @createDate=data['createDate']
38
- @createDateString=data['createDateString']
39
- @fellowPlayers=[]
40
- if(data.has_key? "fellowPlayers")
41
- data['fellowPlayers'].each do |player|
42
- @fellowPlayers << Player.new(player)
43
- end
44
- end
45
- @gameId=data['gameId']
46
- @gameMode=data['gameMode']
47
- @gameType=data['gameType']
48
- @invalid=data['invalid']
49
- @level=data['level']
50
- @mapId=data['mapId']
51
- @spell1=data['spell1']
52
- @spell2=data['spell2']
53
- @statistics = {}
54
- data['stats'].each do |key, stat|
55
- @statistics[key] = stat
56
- end
57
- @subType=data['subType']
58
- @teamId=data['teamId']
59
- end
60
- end
61
-
62
- # player of a game
63
- # @attr [Fixnum] championId ID of played Champion
64
- # @attr [Fixnum] summonerId ID of the summoner
65
- # @attr [Fixnum] teammId ID of the team
66
- class Player
67
- attr_accessor :championId, :summonerId, :teamId
68
-
69
- def initialize(data)
70
- @championId = data['championId']
71
- @summonerId = data['summonerId']
72
- @teamId = data['teamId']
73
- end
74
- end
75
-
76
- end
1
+ module Sightstone
2
+ # match history of a summoner
3
+ # @attr [Fixnum] summonerId ID of the summoner
4
+ # @attr [Array<HistoryGame>] games unsorted list of recently played games
5
+ class MatchHistory
6
+ attr_accessor :games, :summonerId
7
+
8
+ def initialize(data)
9
+ @summonerId = data['summonerId']
10
+ @games = []
11
+ data['games'].each do |game|
12
+ games << HistoryGame.new(game)
13
+ end
14
+ end
15
+ end
16
+
17
+ # A played game
18
+ # @attr [Fixnum] championId ID of the played champ of requested summoner
19
+ # @attr [Fixnum] createDate UNIX timestamp of creation date of the games
20
+ # @attr [Array<Player>] fellowPlayers a list of all players of the game
21
+ # @attr [Fixnum] gameId ID of the game
22
+ # @attr [String] gameMode mode of the game
23
+ # @attr [String] gameType type of the game
24
+ # @attr [Boolean] invalid Invalid flag #TODO what is this?
25
+ # @attr [Fixnum] level level of the requested summoner
26
+ # @attr [Fixnum] mapId ID of the played map
27
+ # @attr [Fixnum] spell1 selected summoner spell no 1
28
+ # @attr [Fixnum] spell2 selected summoner spell no 2
29
+ # @attr [String] subtype subtype
30
+ # @attr [Fixnum] teamId ID of the team if there is a team associated to the game
31
+ # @attr [Hash<String, Fixnum, Boolean>] statistics statistics of the game as a Hash: name -> value
32
+ class HistoryGame
33
+ attr_accessor :championId, :createDate, :fellowPlayers, :gameId, :gameMode, :gameType, :invalid, :level, :mapId, :spell1, :spell2, :statistics, :subType, :teamId
34
+
35
+ def initialize(data)
36
+ @championId=data['championId']
37
+ @createDate=data['createDate']
38
+ @createDateString=data['createDateString']
39
+ @fellowPlayers=[]
40
+ if(data.has_key? "fellowPlayers")
41
+ data['fellowPlayers'].each do |player|
42
+ @fellowPlayers << Player.new(player)
43
+ end
44
+ end
45
+ @gameId=data['gameId']
46
+ @gameMode=data['gameMode']
47
+ @gameType=data['gameType']
48
+ @invalid=data['invalid']
49
+ @level=data['level']
50
+ @mapId=data['mapId']
51
+ @spell1=data['spell1']
52
+ @spell2=data['spell2']
53
+ @statistics = {}
54
+ data['stats'].each do |key, stat|
55
+ @statistics[key] = stat
56
+ end
57
+ @subType=data['subType']
58
+ @teamId=data['teamId']
59
+ end
60
+ end
61
+
62
+ # player of a game
63
+ # @attr [Fixnum] championId ID of played Champion
64
+ # @attr [Fixnum] summonerId ID of the summoner
65
+ # @attr [Fixnum] teammId ID of the team
66
+ class Player
67
+ attr_accessor :championId, :summonerId, :teamId
68
+
69
+ def initialize(data)
70
+ @championId = data['championId']
71
+ @summonerId = data['summonerId']
72
+ @teamId = data['teamId']
73
+ end
74
+ end
75
+
76
+ end
@@ -1,34 +1,34 @@
1
- require 'sightstone/champion'
2
- require 'sightstone/modules/sightstone_base_module'
3
- module Sightstone
4
- # Module to provide calls to the summoner api
5
- class ChampionModule < SightstoneBaseModule
6
-
7
- def initialize(sightstone)
8
- @sightstone = sightstone
9
- end
10
-
11
- # call to get champions
12
- # @param optional [Hash] optional arguments: :region => replaces default region, :free_to_play => boolean (only free to play champs if true)
13
- # @return [Array<Champion>] array of champs
14
- def champions(optional={})
15
- region = optional[:region] || @sightstone.region
16
- free_to_play = optional[:free_to_play]
17
- uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.1/champion"
18
- response = _get_api_response(uri, {'freeToPlay' => free_to_play})
19
-
20
- _parse_response(response) { |resp|
21
- data = JSON.parse(resp)
22
- champions = []
23
- data['champions'].each do |champ|
24
- champions << Champion.new(champ)
25
- end
26
- if block_given?
27
- yield champions
28
- else
29
- return champions
30
- end
31
- }
32
- end
33
- end
1
+ require 'sightstone/champion'
2
+ require 'sightstone/modules/sightstone_base_module'
3
+ module Sightstone
4
+ # Module to provide calls to the summoner api
5
+ class ChampionModule < SightstoneBaseModule
6
+
7
+ def initialize(sightstone)
8
+ @sightstone = sightstone
9
+ end
10
+
11
+ # call to get champions
12
+ # @param optional [Hash] optional arguments: :region => replaces default region, :free_to_play => boolean (only free to play champs if true)
13
+ # @return [Array<Champion>] array of champs
14
+ def champions(optional={})
15
+ region = optional[:region] || @sightstone.region
16
+ free_to_play = optional[:free_to_play]
17
+ uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.1/champion"
18
+ response = _get_api_response(uri, {'freeToPlay' => free_to_play})
19
+
20
+ _parse_response(response) { |resp|
21
+ data = JSON.parse(resp)
22
+ champions = []
23
+ data['champions'].each do |champ|
24
+ champions << Champion.new(champ)
25
+ end
26
+ if block_given?
27
+ yield champions
28
+ else
29
+ return champions
30
+ end
31
+ }
32
+ end
33
+ end
34
34
  end
@@ -1,26 +1,26 @@
1
- require 'sightstone/modules/sightstone_base_module'
2
- module Sightstone
3
- class DatadragonModule < SightstoneBaseModule
4
-
5
- def initialize(sightstone)
6
- @sightstone = sightstone
7
- end
8
-
9
- def version(optional={})
10
- region = optional[:region] || @sightstone.region
11
- uri = "https://ddragon.leagueoflegends.com/realms/#{region}.json"
12
-
13
- response = _get_api_response(uri)
14
- _parse_response(response) { |resp|
15
- data = JSON.parse(resp)
16
- if block_given?
17
- yield data['v']
18
- else
19
- return data['v']
20
- end
21
- }
22
- end
23
-
24
-
25
- end
1
+ require 'sightstone/modules/sightstone_base_module'
2
+ module Sightstone
3
+ class DatadragonModule < SightstoneBaseModule
4
+
5
+ def initialize(sightstone)
6
+ @sightstone = sightstone
7
+ end
8
+
9
+ def version(optional={})
10
+ region = optional[:region] || @sightstone.region
11
+ uri = "https://ddragon.leagueoflegends.com/realms/#{region}.json"
12
+
13
+ response = _get_api_response(uri)
14
+ _parse_response(response) { |resp|
15
+ data = JSON.parse(resp)
16
+ if block_given?
17
+ yield data['v']
18
+ else
19
+ return data['v']
20
+ end
21
+ }
22
+ end
23
+
24
+
25
+ end
26
26
  end
@@ -1,39 +1,39 @@
1
- require 'sightstone/modules/sightstone_base_module'
2
- require 'sightstone/summoner'
3
- require 'sightstone/match_history'
4
- module Sightstone
5
- # module to access the game api
6
- class GameModule < SightstoneBaseModule
7
-
8
- def initialize(sightstone)
9
- @sightstone = sightstone
10
- end
11
-
12
- # returns the match history of a summoner
13
- # @param [Summoner, Fixnum] summoner summoner object or id of a summoner
14
- # @param optional [Hash] optional arguments: :region => replaces default region
15
- # @return [MatchHistory] match history of the summoner
16
- def recent(summoner, optional={})
17
- region = optional[:region] || @sightstone.region
18
- id = if summoner.is_a? Summoner
19
- summoner.id
20
- else
21
- summoner
22
- end
23
- uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.3/game/by-summoner/#{id}/recent"
24
-
25
- response = _get_api_response(uri)
26
- _parse_response(response) { |resp|
27
- data = JSON.parse(resp)
28
- history = MatchHistory.new(data)
29
- if block_given?
30
- yield history
31
- else
32
- return history
33
- end
34
- }
35
- end
36
-
37
-
38
- end
1
+ require 'sightstone/modules/sightstone_base_module'
2
+ require 'sightstone/summoner'
3
+ require 'sightstone/match_history'
4
+ module Sightstone
5
+ # module to access the game api
6
+ class GameModule < SightstoneBaseModule
7
+
8
+ def initialize(sightstone)
9
+ @sightstone = sightstone
10
+ end
11
+
12
+ # returns the match history of a summoner
13
+ # @param [Summoner, Fixnum] summoner summoner object or id of a summoner
14
+ # @param optional [Hash] optional arguments: :region => replaces default region
15
+ # @return [MatchHistory] match history of the summoner
16
+ def recent(summoner, optional={})
17
+ region = optional[:region] || @sightstone.region
18
+ id = if summoner.is_a? Summoner
19
+ summoner.id
20
+ else
21
+ summoner
22
+ end
23
+ uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.3/game/by-summoner/#{id}/recent"
24
+
25
+ response = _get_api_response(uri)
26
+ _parse_response(response) { |resp|
27
+ data = JSON.parse(resp)
28
+ history = MatchHistory.new(data)
29
+ if block_given?
30
+ yield history
31
+ else
32
+ return history
33
+ end
34
+ }
35
+ end
36
+
37
+
38
+ end
39
39
  end
@@ -1,69 +1,69 @@
1
- require 'sightstone/modules/sightstone_base_module'
2
- require 'sightstone/summoner'
3
- require 'sightstone/league'
4
-
5
- module Sightstone
6
- # module to provide calls to the league api
7
- class LeagueModule < SightstoneBaseModule
8
- def initialize(sightstone)
9
- @sightstone = sightstone
10
- end
11
-
12
- # Provides league information of a summoner
13
- # @param [Summoner, Integer] summoner
14
- # @param optional [Hash] optional arguments: :region => replaces default region
15
- # @return [Array<League>] an array of all leagues the summoner and his teams are in
16
- def leagues(summoner, optional={})
17
- region = optional[:region] || @sightstone.region
18
- id = if summoner.is_a? Summoner
19
- summoner.id
20
- else
21
- summoner
22
- end
23
-
24
- uri = "https://prod.api.pvp.net/api/lol/#{region}/v2.3/league/by-summoner/#{id}"
25
- response = _get_api_response(uri)
26
- _parse_response(response) { |resp|
27
- data = JSON.parse(resp)
28
- leagues = []
29
- data.each do |league|
30
- leagues << League.new(league)
31
- end
32
- if block_given?
33
- yield leagues
34
- else
35
- return leagues
36
- end
37
- }
38
- end
39
-
40
- # Get all entries for the given summoner
41
- # @param [Summoner, Integer] summoner or summoner id
42
- # @param optional [Hash] optional arguments: :region => replaces default region
43
- # @return [Array<LeagueItem>] an array of all entries for that given summoner
44
- def league_entries(summoner, optional={})
45
- region = optional[:region] || @sightstone.region
46
- id = if summoner.is_a? Summoner
47
- summoner.id
48
- else
49
- summoner
50
- end
51
-
52
- uri = "https://prod.api.pvp.net/api/lol/#{region}/v2.3/league/by-summoner/#{id}/entry"
53
- response = _get_api_response(uri)
54
- _parse_response(response) { |resp|
55
- data = JSON.parse(resp)
56
- entries = []
57
- data.each do |entry|
58
- entries << LeagueItem.new(entry)
59
- end
60
- if block_given?
61
- yield entries
62
- else
63
- return entries
64
- end
65
- }
66
- end
67
-
68
- end
1
+ require 'sightstone/modules/sightstone_base_module'
2
+ require 'sightstone/summoner'
3
+ require 'sightstone/league'
4
+
5
+ module Sightstone
6
+ # module to provide calls to the league api
7
+ class LeagueModule < SightstoneBaseModule
8
+ def initialize(sightstone)
9
+ @sightstone = sightstone
10
+ end
11
+
12
+ # Provides league information of a summoner
13
+ # @param [Summoner, Integer] summoner
14
+ # @param optional [Hash] optional arguments: :region => replaces default region
15
+ # @return [Array<League>] an array of all leagues the summoner and his teams are in
16
+ def leagues(summoner, optional={})
17
+ region = optional[:region] || @sightstone.region
18
+ id = if summoner.is_a? Summoner
19
+ summoner.id
20
+ else
21
+ summoner
22
+ end
23
+
24
+ uri = "https://prod.api.pvp.net/api/lol/#{region}/v2.3/league/by-summoner/#{id}"
25
+ response = _get_api_response(uri)
26
+ _parse_response(response) { |resp|
27
+ data = JSON.parse(resp)
28
+ leagues = []
29
+ data.each do |league|
30
+ leagues << League.new(league)
31
+ end
32
+ if block_given?
33
+ yield leagues
34
+ else
35
+ return leagues
36
+ end
37
+ }
38
+ end
39
+
40
+ # Get all entries for the given summoner
41
+ # @param [Summoner, Integer] summoner or summoner id
42
+ # @param optional [Hash] optional arguments: :region => replaces default region
43
+ # @return [Array<LeagueItem>] an array of all entries for that given summoner
44
+ def league_entries(summoner, optional={})
45
+ region = optional[:region] || @sightstone.region
46
+ id = if summoner.is_a? Summoner
47
+ summoner.id
48
+ else
49
+ summoner
50
+ end
51
+
52
+ uri = "https://prod.api.pvp.net/api/lol/#{region}/v2.3/league/by-summoner/#{id}/entry"
53
+ response = _get_api_response(uri)
54
+ _parse_response(response) { |resp|
55
+ data = JSON.parse(resp)
56
+ entries = []
57
+ data.each do |entry|
58
+ entries << LeagueItem.new(entry)
59
+ end
60
+ if block_given?
61
+ yield entries
62
+ else
63
+ return entries
64
+ end
65
+ }
66
+ end
67
+
68
+ end
69
69
  end