fantasy-football 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fantasy_football/CLI.rb +3 -2
- data/lib/fantasy_football/player.rb +1 -1
- data/lib/fantasy_football/scraper.rb +4 -3
- data/lib/fantasy_football/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5a59bd1cc3884b50de0f7fe08b14a0477000cae4d74b12e1fc26a8c806a598a
|
4
|
+
data.tar.gz: c2208dc6a42677c479d58f65ead6ff7a01a041d7349e456019c4a52bee4567ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd9c8efb194ab0cf4e5332997d4e90d7723275e994f5e1ef5db6202be9503bf52b6d4d8b5c9fb325beb3c7aa3f4d95f7c0ba922ff7b97d8d443e586e9dbf4d8c
|
7
|
+
data.tar.gz: 272c79fa3c56869d9cdc808d1a96d842afdd171876634ade6ae3d01dfc169dfa7eb8662ce010126daba2c5a4b844a74b86d1fe2456ea7b80cfabf4a3e8ac49b8
|
data/lib/fantasy_football/CLI.rb
CHANGED
@@ -26,8 +26,9 @@ class FantasyFootball::CLI
|
|
26
26
|
def print_rankings
|
27
27
|
# Iterates through Player.all to print player name and rankings by position
|
28
28
|
puts " "
|
29
|
-
|
30
|
-
|
29
|
+
FantasyFootball::Player.find_by_position(position).sort {|a,b| a.rank.to_i <=> b.rank.to_i}.each_with_index {| p, i|
|
30
|
+
puts "-- Top #{FantasyFootball::Scraper.size} #{position.upcase}s for Week #{p.week} of #{Time.new.year} --" if i == 0
|
31
|
+
puts "#{p.rank}. #{p.name}"}
|
31
32
|
puts " "
|
32
33
|
end
|
33
34
|
|
@@ -3,7 +3,7 @@ class FantasyFootball::Player
|
|
3
3
|
extend Findable::ClassMethods
|
4
4
|
include Memorable::InstanceMethods
|
5
5
|
|
6
|
-
attr_accessor :name, :position, :projection, :team, :height, :weight, :age, :college, :rank, :url
|
6
|
+
attr_accessor :name, :position, :projection, :team, :height, :weight, :age, :college, :rank, :url, :week
|
7
7
|
|
8
8
|
@@all = []
|
9
9
|
|
@@ -7,12 +7,12 @@ class FantasyFootball::Scraper
|
|
7
7
|
def self.scrape_rankings(position)
|
8
8
|
doc = Nokogiri::HTML(open("https://www.fantasypros.com/nfl/rankings/#{position}.php"))
|
9
9
|
# binding.pry
|
10
|
-
|
10
|
+
week = doc.css('h1').text.split[5]
|
11
11
|
table = doc.css('tbody tr') # Selects the HTML table with player rankings
|
12
|
-
build_players(table, position)
|
12
|
+
build_players(table, position, week)
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.build_players(table,position)
|
15
|
+
def self.build_players(table, position, week)
|
16
16
|
# Input is HTML table of player rankings, instantiates Players, assigns name, rank, and url
|
17
17
|
table.each_with_index do |t, i|
|
18
18
|
if i < size
|
@@ -20,6 +20,7 @@ class FantasyFootball::Scraper
|
|
20
20
|
p.name = [t.text.split[1], t.text.split[3]].join(" ")
|
21
21
|
p.rank = t.text.split[0]
|
22
22
|
p.url = "https://www.fantasypros.com" + t.css('a')[0]["href"]
|
23
|
+
p.week = week
|
23
24
|
p.position = position.upcase
|
24
25
|
end
|
25
26
|
end
|