class OverwatchStats::CLI

Attributes

stats[RW]

Public Instance Methods

check_width(string, index = 1, column_width = 13) click to toggle source
# File lib/cli.rb, line 200
def check_width(string, index = 1, column_width = 13)
  if index < 10 && string.size <= column_width
    add_space = column_width - string.size - 1
    add_space.times do
      string = string + " "
    end
    string
  elsif index > 9 && string.size <= column_width
    add_space = column_width - string.size - 2
    add_space.times do
      string = string + " "
    end
  end
  string
end
display_bastion() click to toggle source

def display_bastion

array = OverwatchStats::Hero.hero_collect
array.each do |x|
  if x.name.downcase == "bastion"
    puts "Name: #{x.name}"
    puts "Role: #{x.role}"
    puts ""
    puts "Lore: #{x.lore}"
    puts ""
    puts "Max HP: #{x.hp}" unless x.hp == nil
    puts "Ammo: #{x.ammo}" unless x.ammo == nil
    puts ""
    puts "**Abilities**"
    puts "------------------------"
    x.abilities.each do |ability|
      puts "Ability: #{ability[:ability_name]}"
      puts "Description: " + "#{ability[:ability_description]}"
      puts ""
    end
  else
    menu
  end
end

end

# File lib/cli.rb, line 243
def display_bastion
  x = OverwatchStats::Hero.bastion
  show_stats(x)
end
display_dva() click to toggle source
# File lib/cli.rb, line 248
def display_dva
  x = OverwatchStats::Hero.dva
  show_stats(x)
end
display_genji() click to toggle source
# File lib/cli.rb, line 253
def display_genji
  x = OverwatchStats::Hero.genji
  show_stats(x)
end
display_hanzo() click to toggle source
# File lib/cli.rb, line 258
def display_hanzo
  x = OverwatchStats::Hero.hanzo
  show_stats(x)
end
display_junkrat() click to toggle source
# File lib/cli.rb, line 263
def display_junkrat
  x = OverwatchStats::Hero.junkrat
  show_stats(x)
end
display_lucio() click to toggle source
# File lib/cli.rb, line 268
def display_lucio
  x = OverwatchStats::Hero.lucio
  show_stats(x)
end
display_mccree() click to toggle source
# File lib/cli.rb, line 273
def display_mccree
  x = OverwatchStats::Hero.mccree
  show_stats(x)
end
display_mei() click to toggle source
# File lib/cli.rb, line 278
def display_mei
  x = OverwatchStats::Hero.mei
  show_stats(x)
end
display_pharah() click to toggle source
# File lib/cli.rb, line 283
def display_pharah
  x = OverwatchStats::Hero.pharah
  show_stats(x)
end
display_reaper() click to toggle source
# File lib/cli.rb, line 288
def display_reaper
  x = OverwatchStats::Hero.reaper
  show_stats(x)
end
display_reinhardt() click to toggle source
# File lib/cli.rb, line 293
def display_reinhardt
  x = OverwatchStats::Hero.reinhardt
  show_stats(x)
end
display_roadhog() click to toggle source
# File lib/cli.rb, line 298
def display_roadhog
  x = OverwatchStats::Hero.roadhog
  show_stats(x)
end
display_soldier76() click to toggle source
# File lib/cli.rb, line 303
def display_soldier76
  x = OverwatchStats::Hero.soldier76
  show_stats(x)
end
display_stats_alphabetically() click to toggle source
# File lib/cli.rb, line 109
def display_stats_alphabetically
  stats = OverwatchStats::StatScraper.current
  byalph = stats.sort_by {|hash| hash[:heroname]}
  puts ""
  puts "                        Stats Sorted Alphabetically"
  puts "==================================================================================="
  puts "||       HERO      ||   TYPE  || WINRATE || POPULARITY || MEDALS/GM || K/D Ratio ||"
  byalph.each.with_index(1) do |herostats, index|
    show_heroname = check_width(herostats[:heroname], index)
    show_herotype = check_width(herostats[:herotype], 1 , 8)
    show_winrate = check_width(herostats[:winrate], 1 , 7)
    show_popularity = check_width(herostats[:popularity], 1 , 8)
    show_medalpergame = check_width(herostats[:medalpergame], 1 , 8)
    show_herokd = check_width(herostats[:herokd], 1 , 8)
    puts "|| #{index}. #{show_heroname} || #{show_herotype} ||  #{show_winrate} ||    #{show_popularity} ||   #{show_medalpergame} ||   #{show_herokd} ||"
  end
  puts "==================================================================================="
end
display_stats_herokd() click to toggle source
# File lib/cli.rb, line 182
def display_stats_herokd
  stats = OverwatchStats::StatScraper.current
  byherokd = stats.sort_by {|hash| hash[:herokd].to_f}.reverse
  puts "                             Stats Sorted by Herokd"
  puts "==================================================================================="
  puts "||       HERO      ||   TYPE  || WINRATE || POPULARITY || MEDALS/GM || K/D Ratio ||"
  byherokd.each.with_index(1) do |herostats, index|
    show_heroname = check_width(herostats[:heroname], index)
    show_herotype = check_width(herostats[:herotype], 1 , 8)
    show_winrate = check_width(herostats[:winrate], 1 , 7)
    show_popularity = check_width(herostats[:popularity], 1 , 8)
    show_medalpergame = check_width(herostats[:medalpergame], 1 , 8)
    show_herokd = check_width(herostats[:herokd], 1 , 8)
    puts "|| #{index}. #{show_heroname} || #{show_herotype} ||  #{show_winrate} ||    #{show_popularity} ||   #{show_medalpergame} ||   #{show_herokd} ||"
  end
  puts "==================================================================================="
end
display_stats_medalpergame() click to toggle source
# File lib/cli.rb, line 164
def display_stats_medalpergame
  stats = OverwatchStats::StatScraper.current
  bymedalpergame = stats.sort_by {|hash| hash[:medalpergame].to_f}.reverse
  puts "                        Stats Sorted by Medal/Game"
  puts "==================================================================================="
  puts "||       HERO      ||   TYPE  || WINRATE || POPULARITY || MEDALS/GM || K/D Ratio ||"
  bymedalpergame.each.with_index(1) do |herostats, index|
    show_heroname = check_width(herostats[:heroname], index)
    show_herotype = check_width(herostats[:herotype], 1 , 8)
    show_winrate = check_width(herostats[:winrate], 1 , 7)
    show_popularity = check_width(herostats[:popularity], 1 , 8)
    show_medalpergame = check_width(herostats[:medalpergame], 1 , 8)
    show_herokd = check_width(herostats[:herokd], 1 , 8)
    puts "|| #{index}. #{show_heroname} || #{show_herotype} ||  #{show_winrate} ||    #{show_popularity} ||   #{show_medalpergame} ||   #{show_herokd} ||"
  end
  puts "==================================================================================="
end
display_stats_popularity() click to toggle source
# File lib/cli.rb, line 146
def display_stats_popularity
  stats = OverwatchStats::StatScraper.current
  bypopularity = stats.sort_by {|hash| hash[:popularity]}.reverse
  puts "                         Stats Sorted by Popularity"
  puts "==================================================================================="
  puts "||       HERO      ||   TYPE  || WINRATE || POPULARITY || MEDALS/GM || K/D Ratio ||"
  bypopularity.each.with_index(1) do |herostats, index|
    show_heroname = check_width(herostats[:heroname], index)
    show_herotype = check_width(herostats[:herotype], 1 , 8)
    show_winrate = check_width(herostats[:winrate], 1 , 7)
    show_popularity = check_width(herostats[:popularity], 1 , 8)
    show_medalpergame = check_width(herostats[:medalpergame], 1 , 8)
    show_herokd = check_width(herostats[:herokd], 1 , 8)
    puts "|| #{index}. #{show_heroname} || #{show_herotype} ||  #{show_winrate} ||    #{show_popularity} ||   #{show_medalpergame} ||   #{show_herokd} ||"
  end
  puts "==================================================================================="
end
display_stats_winrate() click to toggle source
# File lib/cli.rb, line 128
def display_stats_winrate
  stats = OverwatchStats::StatScraper.current
  bywinrate = stats.sort_by {|hash| hash[:winrate]}.reverse
  puts "                          Stats Sorted by Winrate"
  puts "==================================================================================="
  puts "||       HERO      ||   TYPE  || WINRATE || POPULARITY || MEDALS/GM || K/D Ratio ||"
  bywinrate.each.with_index(1) do |herostats, index|
    show_heroname = check_width(herostats[:heroname], index)
    show_herotype = check_width(herostats[:herotype], 1 , 8)
    show_winrate = check_width(herostats[:winrate], 1 , 7)
    show_popularity = check_width(herostats[:popularity], 1 , 8)
    show_medalpergame = check_width(herostats[:medalpergame], 1 , 8)
    show_herokd = check_width(herostats[:herokd], 1 , 8)
    puts "|| #{index}. #{show_heroname} || #{show_herotype} ||  #{show_winrate} ||    #{show_popularity} ||   #{show_medalpergame} ||   #{show_herokd} ||"
  end
  puts "==================================================================================="
end
display_symmetra() click to toggle source
# File lib/cli.rb, line 308
def display_symmetra
  x = OverwatchStats::Hero.symmetra
  show_stats(x)
end
display_torbjorn() click to toggle source
# File lib/cli.rb, line 313
def display_torbjorn
  x = OverwatchStats::Hero.torbjorn
  show_stats(x)
end
display_tracer() click to toggle source
# File lib/cli.rb, line 318
def display_tracer
  x = OverwatchStats::Hero.tracer
  show_stats(x)
end
display_widowmaker() click to toggle source
# File lib/cli.rb, line 323
def display_widowmaker
  x = OverwatchStats::Hero.widowmaker
  show_stats(x)
end
display_winston() click to toggle source
# File lib/cli.rb, line 328
def display_winston
  x = OverwatchStats::Hero.winston
  show_stats(x)
end
display_zarya() click to toggle source
# File lib/cli.rb, line 333
def display_zarya
  x = OverwatchStats::Hero.zarya
  show_stats(x)
end
display_zenyatta() click to toggle source
# File lib/cli.rb, line 338
def display_zenyatta
  x = OverwatchStats::Hero.zenyatta
  show_stats(x)
end
greeting() click to toggle source
# File lib/cli.rb, line 11
def greeting
  puts ""
  puts "                   Cheers Love! Welcome to OverwatchStats!"
end
menu() click to toggle source
show_stats(x) click to toggle source
# File lib/cli.rb, line 343
def show_stats(x)
  puts "Name: #{x.name}"
  puts ""
  puts "Role: #{x.role}"
  puts "Max HP: #{x.hp}" unless x.hp == nil
  puts "Ammo: #{x.ammo}" unless x.ammo == nil
  puts ""
  puts "Lore: #{x.lore}"
  puts ""
  puts ""
  puts "**Abilities**"
  puts "------------------------"
  x.abilities.each do |ability|
    puts "Ability: #{ability[:ability_name]}"
    puts "Description: " + "#{ability[:ability_description]}"
    puts ""
  end
end
start() click to toggle source
# File lib/cli.rb, line 5
def start
  greeting
  display_stats_alphabetically
  menu
end