Class: Content

Inherits:
Object
  • Object
show all
Defined in:
lib/api/utils/content.rb

Overview

This class is used to create a Content object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Content

Returns a new instance of Content.



9
10
11
12
13
# File 'lib/api/utils/content.rb', line 9

def initialize(data)
  @data = data
  @assets = fetch_assets
  remove_instance_variable(:@data)
end

Instance Attribute Details

#assetsObject (readonly)

Returns the value of attribute assets.



7
8
9
# File 'lib/api/utils/content.rb', line 7

def assets
  @assets
end

Instance Method Details

#agent_images(name) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/api/utils/content.rb', line 19

def agent_images(name)
  agent = @assets.find { |asset| asset.name == name }
  { display_icon: "https://media.valorant-api.com/agents/#{agent.id}/displayicon.png",
    display_icon_small: "https://media.valorant-api.com/agents/#{agent.id}/displayiconsmall.png",
    bust_portrait: "https://media.valorant-api.com/agents/#{agent.id}/fullportrait.png",
    full_portrait: "https://media.valorant-api.com/agents/#{agent.id}/fullportrait.png",
    full_portrait_v2: "https://media.valorant-api.com/agents/#{agent.id}/fullportrait.png",
    killfeed_portrait: "https://media.valorant-api.com/agents/#{agent.id}/killfeedportrait.png",
    background: "https://media.valorant-api.com/agents/#{agent.id}/background.png" }
end

#find_asset_by_name(name) ⇒ Object



15
16
17
# File 'lib/api/utils/content.rb', line 15

def find_asset_by_name(name)
  @assets.find { |asset| asset.name == name }
end