documentation

This commit is contained in:
danijoo
2013-12-15 01:56:26 +01:00
parent 6600841e8a
commit 382ec39185
2 changed files with 25 additions and 4 deletions

View File

@@ -7,10 +7,23 @@ require 'sightstone/modules/league_module'
require 'sightstone/modules/stats_module' require 'sightstone/modules/stats_module'
require 'sightstone/modules/team_module' require 'sightstone/modules/team_module'
# This is the main class of the Sightstone gem. All calls should be perfomrmed through this class.
# @attr [String] region The default region
# @attr [String] api_key Your api key
# @attr [SummonerModule] summoner Module to call the summoners api
# @attr [ChampionModule] Champion module to call the champion api
# @attr [GameModule] Game module to call the game api
# @attr [LeagueModule] League module to call the leagues api
# @attr [StatsModule] Stats module to call the stats api
# @attr [TeamModule] Team module to call the team api
class Sightstone class Sightstone
attr_accessor :region, :api_key
attr_accessor :region
attr_accessor :api_key
attr_accessor :summoner, :champion, :game, :league, :stats, :team attr_accessor :summoner, :champion, :game, :league, :stats, :team
# @param api_key [String] Riot developer api key
# @param region [String] The default region to be used. See riots dev. page for supported regions.
def initialize(api_key, region='euw') def initialize(api_key, region='euw')
@api_key = api_key @api_key = api_key
@region = region @region = region
@@ -24,11 +37,14 @@ class Sightstone
end end
end end
# Error classes # Base class for exceptions raised by the gem
class SightstoneApiException < Exception; end class SightstoneApiException < Exception; end
# Raised if the given developer cannot be found (api returns http error code 404)
class SummonerNotFoundException < SightstoneApiException; end class SummonerNotFoundException < SightstoneApiException; end
# Raised if the connection to the api failed
class SightstoneConnectionException < SightstoneApiException; end class SightstoneConnectionException < SightstoneApiException; end
# Raised when the RateLimit has been exceeded (api returns http error code 429)
class RateLimitExceededException < SightstoneApiException; end class RateLimitExceededException < SightstoneApiException; end

View File

@@ -1,9 +1,14 @@
# Class to represent a summoner
# @attr [String] name name
# @attr [Long] id summoner id (used for other calls)
# @attr [Integer] profileIconId profile icon id of the summoner
# @attr [long] revisionDate timestamp of latest data change
# @attr [Integer] level summoner level
class Summoner class Summoner
attr_accessor :name, :id, :profileIconId, :revisionDate, :level attr_accessor :name, :id, :profileIconId, :revisionDate, :level
# @param data [Hash] json hash representation of the summoner
def initialize(data) def initialize(data)
@name = data['name'] @name = data['name']
@id = data['id'] @id = data['id']