diff --git a/lib/sightstone.rb b/lib/sightstone.rb index 2639d7b..a3201c3 100644 --- a/lib/sightstone.rb +++ b/lib/sightstone.rb @@ -7,10 +7,23 @@ require 'sightstone/modules/league_module' require 'sightstone/modules/stats_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 - attr_accessor :region, :api_key + + attr_accessor :region + attr_accessor :api_key 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') @api_key = api_key @region = region @@ -24,11 +37,14 @@ class Sightstone end end -# Error classes +# Base class for exceptions raised by the gem class SightstoneApiException < Exception; end +# Raised if the given developer cannot be found (api returns http error code 404) class SummonerNotFoundException < SightstoneApiException; end +# Raised if the connection to the api failed class SightstoneConnectionException < SightstoneApiException; end +# Raised when the RateLimit has been exceeded (api returns http error code 429) class RateLimitExceededException < SightstoneApiException; end diff --git a/lib/sightstone/summoner.rb b/lib/sightstone/summoner.rb index c5120fc..cdb89e7 100644 --- a/lib/sightstone/summoner.rb +++ b/lib/sightstone/summoner.rb @@ -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 attr_accessor :name, :id, :profileIconId, :revisionDate, :level + # @param data [Hash] json hash representation of the summoner def initialize(data) @name = data['name'] @id = data['id']