Class: RiotKit::Models::DataDragon::Champion

Inherits:
Object
  • Object
show all
Defined in:
lib/riot_kit/models/data_dragon/champion.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, key:, name:, title: '') ⇒ Champion

Returns a new instance of Champion.



9
10
11
12
13
14
# File 'lib/riot_kit/models/data_dragon/champion.rb', line 9

def initialize(id:, key:, name:, title: '')
  @id = id
  @key = key
  @name = name
  @title = title
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/riot_kit/models/data_dragon/champion.rb', line 7

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/riot_kit/models/data_dragon/champion.rb', line 7

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/riot_kit/models/data_dragon/champion.rb', line 7

def name
  @name
end

#titleObject (readonly)

Returns the value of attribute title.



7
8
9
# File 'lib/riot_kit/models/data_dragon/champion.rb', line 7

def title
  @title
end

Class Method Details

.from_hash(hash) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/riot_kit/models/data_dragon/champion.rb', line 16

def self.from_hash(hash)
  symbolized = RiotKit::Util::Symbolize.deep_symbolize_keys(hash)
  new(
    id: symbolized[:id].to_i,
    key: symbolized[:key].to_s,
    name: symbolized[:name].to_s,
    title: symbolized[:title].to_s
  )
end

Instance Method Details

#to_hObject



26
27
28
# File 'lib/riot_kit/models/data_dragon/champion.rb', line 26

def to_h
  { id: id, key: key, name: name, title: title }
end