Class: Hero

Inherits:
Object
  • Object
show all
Defined in:
lib/D3/hero.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#deadObject

Returns the value of attribute dead.



5
6
7
# File 'lib/D3/hero.rb', line 5

def dead
  @dead
end

#genderObject

Returns the value of attribute gender.



5
6
7
# File 'lib/D3/hero.rb', line 5

def gender
  @gender
end

#hardcoreObject

Returns the value of attribute hardcore.



5
6
7
# File 'lib/D3/hero.rb', line 5

def hardcore
  @hardcore
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/D3/hero.rb', line 5

def id
  @id
end

#last_updatedObject

Returns the value of attribute last_updated.



5
6
7
# File 'lib/D3/hero.rb', line 5

def last_updated
  @last_updated
end

#levelObject

Returns the value of attribute level.



5
6
7
# File 'lib/D3/hero.rb', line 5

def level
  @level
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/D3/hero.rb', line 5

def name
  @name
end