class RubyGg::Champion

Attributes

champion_url[R]

Public Class Methods

new(api_key, region) click to toggle source
# File lib/ruby_gg/champion.rb, line 8
def initialize(api_key, region) #Initializing the Challenger Instance.
    @api_key = api_key
    @region = region
    @base_url = "https://#{@region}.api.riotgames.com"
    @champion_url = "/lol/league/v3/challengerleagues/by-queue/"
    @leagueVer = HTTParty.get('https://ddragon.leagueoflegends.com/api/versions.json').parsed_response[0]
end

Public Instance Methods

get_name(id) click to toggle source
# File lib/ruby_gg/champion.rb, line 16
def get_name(id)
    champNames = {
                '266' => 'Aatrox',
                '103' => 'Ahri',
                '84' => 'Akali', 
                '12' => 'Alistar', 
                '32' => 'Amumu', 
                '34' => 'Anivia', 
                '1' => 'Annie', 
                '22' => 'Ashe', 
                '136' => 'AurelionSol',
                '268' => 'Azir',
                '432' => 'Bard',
                '53' => 'Blitzcrank',
                '63' => 'Brand',
                '201' => 'Braum',
                '51' => 'Caitlyn',
                '164' => 'Camille',
                '69' => 'Cassiopeia',
                '31' => 'Chogath',
                '42' => 'Corki',
                '122' => 'Darius',
                '131' => 'Diana',
                '36' => 'DrMundo',
                '119' => 'Draven',
                '245' => 'Ekko',
                '60' => 'Elise',
                '28' => 'Evelynn',
                '81' => 'Ezreal',
                '9' => 'Fiddlesticks',
                '114' => 'Fiora',
                '105' => 'Fizz',
                '3' => 'Galio',
                '41' => 'Gangplank',
                '86' => 'Garen',
                '150' => 'Gnar',
                '79' => 'Gragas',
                '104' => 'Graves',
                '120' => 'Hecarim',
                '74' => 'Heimerdinger',
                '420' => 'Illaoi',
                '427' => 'Ivern',
                '39' => 'Irelia',
                '40' => 'Janna',
                '59' => 'JarvanIV',
                '24' => 'Jax',
                '126' => 'Jayce',
                '202' => 'Jhin',
                '222' => 'Jinx',
                '145' => 'Kaisa',
                '429' => 'Kalista',
                '43' => 'Karma',
                '30' => 'Karthus',
                '38' => 'Kassadin',
                '55' => 'Katarina',
                '10' => 'Kayle',
                '141' => 'Kayn',
                '85' => 'Kennen',
                '121' => 'Khazix',
                '203' => 'Kindred',
                '240' => 'Kled',
                '96' => 'KogMaw',
                '7' => 'Leblanc',
                '64' => 'LeeSin',
                '89' => 'Leona',
                '127' => 'Lissandra',
                '236' => 'Lucian',
                '117' => 'Lulu',
                '99' => 'Lux',
                '54' => 'Malphite',
                '90' => 'Malzahar',
                '57' => 'Maokai',
                '11' => 'MasterYi',
                '21' => 'MissFortune',
                '82' => 'Mordekaiser',
                '25' => 'Morgana',
                '267' => 'Nami',
                '75' => 'Nasus',
                '111' => 'Nautilus',
                '76' => 'Nidalee',
                '56' => 'Nocturne',
                '20' => 'Nunu',
                '2' => 'Olaf',
                '61' => 'Orianna',
                '516' => 'Ornn',
                '80' => 'Pantheon',
                '78' => 'Poppy',
                '133' => 'Quinn',
                '497' => 'Rakan',
                '33' => 'Rammus',
                '421' => 'RekSai',
                '58' => 'Renekton',
                '107' => 'Rengar',
                '92' => 'Riven',
                '68' => 'Rumble',
                '13' => 'Ryze',
                '113' => 'Sejuani',
                '35' => 'Shaco',
                '98' => 'Shen',
                '102' => 'Shyvana',
                '27' => 'Singed',
                '14' => 'Sion',
                '15' => 'Sivir',
                '72' => 'Skarner',
                '37' => 'Sona',
                '16' => 'Soraka',
                '50' => 'Swain',
                '134' => 'Syndra',
                '223' => 'TahmKench',
                '163' => 'Taliyah',
                '91' => 'Talon',
                '44' => 'Taric',
                '17' => 'Teemo',
                '412' => 'Thresh',
                '18' => 'Tristana',
                '48' => 'Trundle',
                '23' => 'Tryndamere',
                '4' => 'TwistedFate',
                '29' => 'Twitch',
                '77' => 'Udyr',
                '6' => 'Urgot',
                '110' => 'Varus',
                '67' => 'Vayne',
                '45' => 'Veigar',
                '161' => 'Velkoz',
                '254' => 'Vi',
                '112' => 'Viktor',
                '8' => 'Vladimir',
                '106' => 'Volibear',
                '19' => 'Warwick',
                '62' => 'MonkeyKing',
                '498' => 'Xayah',
                '101' => 'Xerath',
                '5' => 'XinZhao',
                '157' => 'Yasuo',
                '83' => 'Yorick',
                '154' => 'Zac',
                '238' => 'Zed',
                '115' => 'Ziggs',
                '26' => 'Zilean',
                '142' => 'Zoe',
                '143' => 'Zyra'}
    return champNames[id.to_s]
end
icon(champName) click to toggle source
# File lib/ruby_gg/champion.rb, line 161
def icon(champName)
    icon = "https://ddragon.leagueoflegends.com/cdn/#{@leagueVer}/img/champion/#{champName}.png"
    return icon
end
points(points) click to toggle source
# File lib/ruby_gg/champion.rb, line 166
def points(points)
    if points.to_i < 1000
      return points
    elsif points.to_i >= 1000 and points.to_i < 1000000
      fixed = points.to_f/1000.0
      return ('%.1f' % fixed).to_s + ' K'
    elsif points.to_i >= 1000000
      fixed = points.to_f/1000000.0
      return ('%.1f' % fixed).to_s + ' M'
    end
end