ncaa_scrape 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/ncaa_scrape.rb +54 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3d679a1988d8f14de76dbaa4733cd4972d7aa2c6
|
4
|
+
data.tar.gz: 423113a6c4c07997f4e64c7fb513448f52f0f876
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e62a0f1aaf5a4253753503f72df1bf812bd19e52a3e639678e4309b1be0e0384a9122c74caa1a1e0ec1d91c7935e20cb2f02a4a817900afd058dad961a30ac24
|
7
|
+
data.tar.gz: 27c9c6f350591546ccd99d8c72f3d6554dec3099ac42c5d868071c96c647384eb460ae8225ca8c8d2e86619bc2abc00b415252135865a7dca6d8d630dd75f7bf
|
data/lib/ncaa_scrape.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
class NCAABasketball
|
5
|
+
attr_reader :division_one_data
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@rankings_page = Nokogiri::HTML(open('http://www.ncaa.com/rankings/basketball-men/d1/ncaa-mens-basketball-rpi'))
|
9
|
+
@division_one_data = team_names.zip(team_conferences, team_records)
|
10
|
+
end
|
11
|
+
|
12
|
+
def css_attribute(column)
|
13
|
+
".ncaa-rankings-table > tbody > tr > td[#{column}]"
|
14
|
+
end
|
15
|
+
|
16
|
+
def team_names
|
17
|
+
names = []
|
18
|
+
@rankings_page.css(css_attribute(3)).each { |row| names << row.content }
|
19
|
+
names
|
20
|
+
end
|
21
|
+
|
22
|
+
def team_conferences
|
23
|
+
conferences = []
|
24
|
+
@rankings_page.css(css_attribute(4)).each { |row| conferences << row.content }
|
25
|
+
conferences
|
26
|
+
end
|
27
|
+
|
28
|
+
def team_records
|
29
|
+
records = []
|
30
|
+
@rankings_page.css(css_attribute(5)).each { |row| records << row.content }
|
31
|
+
records
|
32
|
+
end
|
33
|
+
|
34
|
+
def team_rankings
|
35
|
+
rankings = {}
|
36
|
+
@division_one_data.each_with_index { |team, index| rankings[index + 1] = team }
|
37
|
+
rankings
|
38
|
+
end
|
39
|
+
|
40
|
+
def team_record(team_name)
|
41
|
+
selected_team = @division_one_data.select { |team| team.include?(team_name) }
|
42
|
+
selected_team.flatten.last
|
43
|
+
end
|
44
|
+
|
45
|
+
def team_wins(team_name)
|
46
|
+
team_record(team_name).partition('-').first.to_i
|
47
|
+
end
|
48
|
+
|
49
|
+
def pick_five_total(*teams)
|
50
|
+
teams.inject(0) do |total, team|
|
51
|
+
total + team_wins(team)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ncaa_scrape
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jen Trudell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: As of January 2016, ncaa_scrape lets you scrape RPI rankings for Division
|
14
|
+
I Men's college basketball from the NCAA website. This gem uses nokogiri to scrape
|
15
|
+
data from ncaa.com; if the NCAA website changes, this gem may fail.
|
16
|
+
email: jtrudell@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/ncaa_scrape.rb
|
22
|
+
homepage: https://rubygems.org/gems/ncaa_scrape
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.4.5
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Scrapes NCAA Men's Div I Basketball RPI Rankings from NCAA.com
|
46
|
+
test_files: []
|