Class: Hero
- Inherits:
-
Object
- Object
- Hero
- Defined in:
- lib/D3/hero.rb
Instance Attribute Summary collapse
-
#dead ⇒ Object
Returns the value of attribute dead.
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#hardcore ⇒ Object
Returns the value of attribute hardcore.
-
#id ⇒ Object
Returns the value of attribute id.
-
#last_updated ⇒ Object
Returns the value of attribute last_updated.
-
#level ⇒ Object
Returns the value of attribute level.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(server, btag, id, info = []) ⇒ Hero
constructor
A new instance of Hero.
Constructor Details
#initialize(server, btag, id, info = []) ⇒ Hero
Returns a new instance of Hero.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/D3/hero.rb', line 7 def initialize(server, btag, id, info=[]) @id = id if info.empty? btag.gsub!('#','-') api_url = URI.escape("http://#{server}.battle.net/api/d3/profile/#{btag}/hero/#{id}") ret = Net::HTTP.get(URI.parse(api_url)) info = JSON(ret) end @name = info['name'] @level = info['level'] @gender = info['gender'] @last_updated = info['last-updated'] @dead = info['dead'] @hardcore = info['hardcore'] end |
Instance Attribute Details
#dead ⇒ Object
Returns the value of attribute dead.
5 6 7 |
# File 'lib/D3/hero.rb', line 5 def dead @dead end |
#gender ⇒ Object
Returns the value of attribute gender.
5 6 7 |
# File 'lib/D3/hero.rb', line 5 def gender @gender end |
#hardcore ⇒ Object
Returns the value of attribute hardcore.
5 6 7 |
# File 'lib/D3/hero.rb', line 5 def hardcore @hardcore end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/D3/hero.rb', line 5 def id @id end |
#last_updated ⇒ Object
Returns the value of attribute last_updated.
5 6 7 |
# File 'lib/D3/hero.rb', line 5 def last_updated @last_updated end |
#level ⇒ Object
Returns the value of attribute level.
5 6 7 |
# File 'lib/D3/hero.rb', line 5 def level @level end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/D3/hero.rb', line 5 def name @name end |