Class: HonStats::Classes::Character
- Inherits:
-
Object
- Object
- HonStats::Classes::Character
- Defined in:
- lib/honstats/character.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#account_id ⇒ Object
(also: #to_i)
readonly
Returns the value of attribute account_id.
-
#building ⇒ Object
readonly
Returns the value of attribute building.
-
#character_name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute character_name.
-
#clan ⇒ Object
readonly
Returns the value of attribute clan.
-
#creep ⇒ Object
readonly
Returns the value of attribute creep.
-
#gamestats ⇒ Object
readonly
Returns the value of attribute gamestats.
-
#hero ⇒ Object
readonly
Returns the value of attribute hero.
-
#last_match ⇒ Object
readonly
Returns the value of attribute last_match.
-
#neutral ⇒ Object
readonly
Returns the value of attribute neutral.
Instance Method Summary collapse
-
#initialize(data, api = nil) ⇒ Character
constructor
A new instance of Character.
Constructor Details
#initialize(data, api = nil) ⇒ Character
Returns a new instance of Character.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/honstats/character.rb', line 13 def initialize(data, api = nil) @api = api if data.is_a?(String) output = data.split(";") split = output[3].split("\"") @account_id = split[1].to_i elsif data.is_a?(Integer) @account_id = data end url = base + @api.requester_file data = Net::HTTP.post_form(URI.parse(url), {"f"=>"get_all_stats", "account_id[0]"=>"#{@account_id}"}) if data.class.to_s == "Net::HTTPOK" data = data.body @account_id = HonStats::API.get_data("account_id", data).to_i @character_name = HonStats::API.get_data("nickname", data).to_s @account = Account.new(data) @building = Building.new(data) @clan = SimpleClan.new(data) @creep = Creep.new(data) @hero = Hero.new(data) @gamestats = GameStats.new(data, @hero, @creep) @last_match = LastMatch.new(data) @neutral = Neutral.new(data) end end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
7 8 9 |
# File 'lib/honstats/character.rb', line 7 def account @account end |
#account_id ⇒ Object (readonly) Also known as: to_i
Returns the value of attribute account_id.
7 8 9 |
# File 'lib/honstats/character.rb', line 7 def account_id @account_id end |
#building ⇒ Object (readonly)
Returns the value of attribute building.
7 8 9 |
# File 'lib/honstats/character.rb', line 7 def building @building end |
#character_name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute character_name.
7 8 9 |
# File 'lib/honstats/character.rb', line 7 def character_name @character_name end |
#clan ⇒ Object (readonly)
Returns the value of attribute clan.
7 8 9 |
# File 'lib/honstats/character.rb', line 7 def clan @clan end |
#creep ⇒ Object (readonly)
Returns the value of attribute creep.
7 8 9 |
# File 'lib/honstats/character.rb', line 7 def creep @creep end |
#gamestats ⇒ Object (readonly)
Returns the value of attribute gamestats.
7 8 9 |
# File 'lib/honstats/character.rb', line 7 def gamestats @gamestats end |
#hero ⇒ Object (readonly)
Returns the value of attribute hero.
7 8 9 |
# File 'lib/honstats/character.rb', line 7 def hero @hero end |
#last_match ⇒ Object (readonly)
Returns the value of attribute last_match.
7 8 9 |
# File 'lib/honstats/character.rb', line 7 def last_match @last_match end |
#neutral ⇒ Object (readonly)
Returns the value of attribute neutral.
7 8 9 |
# File 'lib/honstats/character.rb', line 7 def neutral @neutral end |