Class: RiotKit::Config
- Inherits:
-
Object
- Object
- RiotKit::Config
- Defined in:
- lib/riot_kit/config.rb
Constant Summary collapse
- ROUTING_HOSTS =
{ americas: 'https://americas.api.riotgames.com', europe: 'https://europe.api.riotgames.com', asia: 'https://asia.api.riotgames.com', sea: 'https://sea.api.riotgames.com' }.freeze
- PLATFORM_HOSTS =
{ br1: 'https://br1.api.riotgames.com', na1: 'https://na1.api.riotgames.com', la1: 'https://la1.api.riotgames.com', la2: 'https://la2.api.riotgames.com', oc1: 'https://oc1.api.riotgames.com', euw1: 'https://euw1.api.riotgames.com', eun1: 'https://eun1.api.riotgames.com', tr1: 'https://tr1.api.riotgames.com', ru: 'https://ru.api.riotgames.com', jp1: 'https://jp1.api.riotgames.com', kr: 'https://kr.api.riotgames.com', ph2: 'https://ph2.api.riotgames.com', sg2: 'https://sg2.api.riotgames.com', th2: 'https://th2.api.riotgames.com', tw2: 'https://tw2.api.riotgames.com', vn2: 'https://vn2.api.riotgames.com' }.freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#http_timeout ⇒ Object
Returns the value of attribute http_timeout.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#region ⇒ Object
Returns the value of attribute region.
-
#retry_attempts ⇒ Object
Returns the value of attribute retry_attempts.
-
#retry_base_delay ⇒ Object
Returns the value of attribute retry_base_delay.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #platform_base_url ⇒ Object
- #routing_base_url ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
36 37 38 39 40 41 42 43 44 |
# File 'lib/riot_kit/config.rb', line 36 def initialize @api_key = ENV.fetch('RIOT_API_KEY', nil) @region = :americas @platform = :br1 @http_timeout = 30 @logger = Logger.new($stdout) @retry_attempts = 3 @retry_base_delay = 0.5 end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
33 34 35 |
# File 'lib/riot_kit/config.rb', line 33 def api_key @api_key end |
#http_timeout ⇒ Object
Returns the value of attribute http_timeout.
33 34 35 |
# File 'lib/riot_kit/config.rb', line 33 def http_timeout @http_timeout end |
#logger ⇒ Object
Returns the value of attribute logger.
33 34 35 |
# File 'lib/riot_kit/config.rb', line 33 def logger @logger end |
#platform ⇒ Object
Returns the value of attribute platform.
33 34 35 |
# File 'lib/riot_kit/config.rb', line 33 def platform @platform end |
#region ⇒ Object
Returns the value of attribute region.
33 34 35 |
# File 'lib/riot_kit/config.rb', line 33 def region @region end |
#retry_attempts ⇒ Object
Returns the value of attribute retry_attempts.
33 34 35 |
# File 'lib/riot_kit/config.rb', line 33 def retry_attempts @retry_attempts end |
#retry_base_delay ⇒ Object
Returns the value of attribute retry_base_delay.
33 34 35 |
# File 'lib/riot_kit/config.rb', line 33 def retry_base_delay @retry_base_delay end |
Instance Method Details
#platform_base_url ⇒ Object
52 53 54 55 56 |
# File 'lib/riot_kit/config.rb', line 52 def platform_base_url PLATFORM_HOSTS.fetch(platform.to_sym) do raise Errors::InvalidParams, "Unknown platform: #{platform.inspect}" end end |
#routing_base_url ⇒ Object
46 47 48 49 50 |
# File 'lib/riot_kit/config.rb', line 46 def routing_base_url ROUTING_HOSTS.fetch(region.to_sym) do raise Errors::InvalidParams, "Unknown region: #{region.inspect}" end end |