Class: DotaApiWrapper::Hero
- Defined in:
- lib/dota_api_wrapper/hero.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#heroes ⇒ Object
Returns the value of attribute heroes.
Attributes inherited from Econ
Instance Method Summary collapse
- #find_by_id(id) ⇒ Object
-
#initialize(lang = 'en_us') ⇒ Hero
constructor
A new instance of Hero.
- #retrieve_heroes ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(lang = 'en_us') ⇒ Hero
Returns a new instance of Hero.
7 8 9 10 |
# File 'lib/dota_api_wrapper/hero.rb', line 7 def initialize(lang = 'en_us') super(lang) @heroes = retrieve_heroes end |
Instance Attribute Details
#heroes ⇒ Object
Returns the value of attribute heroes.
5 6 7 |
# File 'lib/dota_api_wrapper/hero.rb', line 5 def heroes @heroes end |
Instance Method Details
#find_by_id(id) ⇒ Object
24 25 26 |
# File 'lib/dota_api_wrapper/hero.rb', line 24 def find_by_id(id) heroes[id] end |
#retrieve_heroes ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dota_api_wrapper/hero.rb', line 12 def retrieve_heroes query_params = { 'key' => API_KEY, 'language' => language } api_result = get('/GetHeroes/v0001', query: query_params, headers: {}) return if api_result.empty? res = {} api_result['result']['heroes'].each { |a| res[a['id']] = a } res end |