Class: RiotKit::Models::DataDragon::Item

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, plaintext: '', gold_total: 0, image_full: '', tags: []) ⇒ Item

Returns a new instance of Item.



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

def initialize(id:, name:, plaintext: '', gold_total: 0, image_full: '', tags: [])
  @id = id
  @name = name
  @plaintext = plaintext
  @gold_total = gold_total
  @image_full = image_full
  @tags = tags
end

Instance Attribute Details

#gold_totalObject (readonly)

Returns the value of attribute gold_total.



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

def gold_total
  @gold_total
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#image_fullObject (readonly)

Returns the value of attribute image_full.



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

def image_full
  @image_full
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#plaintextObject (readonly)

Returns the value of attribute plaintext.



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

def plaintext
  @plaintext
end

#tagsObject (readonly)

Returns the value of attribute tags.



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

def tags
  @tags
end

Class Method Details

.from_hash(hash) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/riot_kit/models/data_dragon/item.rb', line 18

def self.from_hash(hash)
  symbolized = RiotKit::Util::Symbolize.deep_symbolize_keys(hash)
  new(
    id: symbolized[:id],
    name: symbolized[:name],
    plaintext: symbolized[:plaintext].to_s,
    gold_total: symbolized[:gold_total].to_i,
    image_full: symbolized[:image_full].to_s,
    tags: Array(symbolized[:tags])
  )
end

Instance Method Details

#to_hObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/riot_kit/models/data_dragon/item.rb', line 30

def to_h
  {
    id: id,
    name: name,
    plaintext: plaintext,
    gold_total: gold_total,
    image_full: image_full,
    tags: tags
  }
end