class NbaDraft2017::Player
Attributes
age[RW]
apg[RW]
bpg[RW]
fg[RW]
first_name[RW]
former_status[RW]
former_team[RW]
ft[RW]
height[RW]
key_stats[RW]
last_name[RW]
mpg[RW]
name[RW]
nba_team[RW]
pick[RW]
position[RW]
ppg[RW]
profile_url[RW]
round[RW]
rpg[RW]
spg[RW]
three[RW]
tpg[RW]
weight[RW]
Public Class Methods
add_attributes_to_player(player)
click to toggle source
# File lib/nba_draft_2017/player.rb, line 29 def self.add_attributes_to_player(player) attributes = NbaDraft2017::Scraper.scrape_player("http://www.nba.com/draft/2017/prospects/" + player.profile_url) player.add_player_attributes(attributes) player end
add_attributes_to_players()
click to toggle source
# File lib/nba_draft_2017/player.rb, line 35 def self.add_attributes_to_players @@all_attributes = self.all.each do |player| add_attributes_to_player(player) end end
all()
click to toggle source
# File lib/nba_draft_2017/player.rb, line 97 def self.all @@all end
all_attributes()
click to toggle source
# File lib/nba_draft_2017/player.rb, line 93 def self.all_attributes @@all_attributes end
find_player_by_name(player_name)
click to toggle source
# File lib/nba_draft_2017/player.rb, line 20 def self.find_player_by_name(player_name) NbaDraft2017::Player.all.detect { |player| player.name.downcase == player_name.downcase } end
find_player_by_pick(pick)
click to toggle source
# File lib/nba_draft_2017/player.rb, line 24 def self.find_player_by_pick(pick) NbaDraft2017::Player.all.detect { |player| player.pick == pick.to_s } end
former_teams()
click to toggle source
# File lib/nba_draft_2017/player.rb, line 75 def self.former_teams self.all.each do |player| @@former_teams << player.former_team.downcase.strip end @@former_teams.uniq end
nba_teams()
click to toggle source
# File lib/nba_draft_2017/player.rb, line 58 def self.nba_teams self.all.each do |player| @@nba_teams << player.nba_team.downcase.strip end @@nba_teams.uniq end
new(player_hash)
click to toggle source
# File lib/nba_draft_2017/player.rb, line 11 def initialize(player_hash) player_hash.each {|attribute, value| self.send("#{attribute}=", value) } @@all << self end
players_by_former_team(former_team)
click to toggle source
# File lib/nba_draft_2017/player.rb, line 83 def self.players_by_former_team(former_team) puts former_team.upcase.bold.colorize(:green) self.all.each do |player| if player.former_team.downcase == former_team.downcase puts "Rd: ".colorize(:red) +"#{player.round}" + " Pick: ".colorize(:red) +"#{player.pick} #{player.name.upcase.bold.colorize(:blue)} to #{player.nba_team.bold.colorize(:blue)}" end end end
players_by_nba_team(nba_team)
click to toggle source
# File lib/nba_draft_2017/player.rb, line 65 def self.players_by_nba_team(nba_team) puts nba_team.upcase.bold.colorize(:green) self.all.each do |player| if player.nba_team.downcase == nba_team.downcase puts "Rd: ".colorize(:red) +"#{player.round}" + " Pick: ".colorize(:red) +"#{player.pick} #{player.name.upcase.bold.colorize(:blue)} from #{player.former_team.bold.colorize(:blue)}" end end end
stat_greater_than(stat_category, stat_num)
click to toggle source
# File lib/nba_draft_2017/player.rb, line 42 def self.stat_greater_than(stat_category, stat_num) @@all_attributes ||= self.add_attributes_to_players puts "Players with a higher #{stat_category} average than #{stat_num.to_f} include:".colorize(:green) puts "------------------------------------------------------------".bold.colorize(:red) players = self.all.select.with_index(1) do |player, idx| if player.send(stat_category) && player.send(stat_category) > stat_num.to_f puts "Pick: #{idx.to_s.colorize(:green)}. #{player.name.colorize(:green)} - #{player.send(stat_category).to_s.colorize(:red)} #{stat_category}" player end end puts "Nobody!".bold.colorize(:red) if players.empty? puts "------------------------------------------------------------".bold.colorize(:red) end
Public Instance Methods
add_player_attributes(attributes_hash)
click to toggle source
# File lib/nba_draft_2017/player.rb, line 16 def add_player_attributes(attributes_hash) attributes_hash.each { |attribute, value| self.send("#{attribute}=", value) } end