Class: HonStats::Classes::Character

Inherits:
Object
  • Object
show all
Defined in:
lib/honstats/character.rb

Direct Known Subclasses

SearchCharacter

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#accountObject (readonly)

Returns the value of attribute account.



7
8
9
# File 'lib/honstats/character.rb', line 7

def 
  @account
end

#account_idObject (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
end

#buildingObject (readonly)

Returns the value of attribute building.



7
8
9
# File 'lib/honstats/character.rb', line 7

def building
  @building
end

#character_nameObject (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

#clanObject (readonly)

Returns the value of attribute clan.



7
8
9
# File 'lib/honstats/character.rb', line 7

def clan
  @clan
end

#creepObject (readonly)

Returns the value of attribute creep.



7
8
9
# File 'lib/honstats/character.rb', line 7

def creep
  @creep
end

#gamestatsObject (readonly)

Returns the value of attribute gamestats.



7
8
9
# File 'lib/honstats/character.rb', line 7

def gamestats
  @gamestats
end

#heroObject (readonly)

Returns the value of attribute hero.



7
8
9
# File 'lib/honstats/character.rb', line 7

def hero
  @hero
end

#last_matchObject (readonly)

Returns the value of attribute last_match.



7
8
9
# File 'lib/honstats/character.rb', line 7

def last_match
  @last_match
end

#neutralObject (readonly)

Returns the value of attribute neutral.



7
8
9
# File 'lib/honstats/character.rb', line 7

def neutral
  @neutral
end