Class: HoN::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/honclient/stats.rb

Direct Known Subclasses

MatchStats, PlayerHeroStats, PlayerStats

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/honclient/stats.rb', line 36

def method_missing(meth, *args, &block)
  if @stats.has_key?(meth.to_s)
    value = @stats[meth.to_s]
    case value
    when /^\d+/ then value.to_f
    else value
    end
  else
    super(meth, *args, &block)
  end
end

Instance Attribute Details

#statsObject

Returns the value of attribute stats.



3
4
5
# File 'lib/honclient/stats.rb', line 3

def stats
  @stats
end

Instance Method Details

#dump_xml_statsObject



20
21
22
# File 'lib/honclient/stats.rb', line 20

def dump_xml_stats
  @stats
end

#errorObject



32
33
34
# File 'lib/honclient/stats.rb', line 32

def error
  @error
end

#error?Boolean



24
25
26
27
28
29
30
# File 'lib/honclient/stats.rb', line 24

def error?
  if defined? @error
    true
  else
    false
  end
end

#nicknameObject



4
5
6
7
8
9
10
# File 'lib/honclient/stats.rb', line 4

def nickname
  if @stats.has_key? "nickname"
    @stats["nickname"]
  else
    "Unknown"
  end
end

#stat(key) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/honclient/stats.rb', line 12

def stat(key)
  if @stats.has_key? key
    @stats[key]
  else
    return 0
  end
end