Class: NbaLeader::Leader
- Inherits:
-
Object
- Object
- NbaLeader::Leader
- Defined in:
- lib/nba_leader/leader.rb
Constant Summary collapse
- @@page =
Nokogiri::HTML(URI.open("https://www.newsday.com/sports/basketball/nba-career-scoring-leaders-1.22616900"))
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#points ⇒ Object
Returns the value of attribute points.
Class Method Summary collapse
- .scrape_leader_1 ⇒ Object
- .scrape_leader_2 ⇒ Object
- .scrape_leader_3 ⇒ Object
- .scrape_leader_4 ⇒ Object
- .scrape_leader_5 ⇒ Object
- .scrape_leaders ⇒ Object
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/nba_leader/leader.rb', line 2 def name @name end |
#points ⇒ Object
Returns the value of attribute points.
2 3 4 |
# File 'lib/nba_leader/leader.rb', line 2 def points @points end |
Class Method Details
.scrape_leader_1 ⇒ Object
18 19 20 21 22 23 |
# File 'lib/nba_leader/leader.rb', line 18 def self.scrape_leader_1 leader = self.new leader.name = @@page.search("h4")[0].text.split(". ")[1] leader.points = @@page.search("p")[6].text.split("T")[0] leader end |
.scrape_leader_2 ⇒ Object
25 26 27 28 29 30 |
# File 'lib/nba_leader/leader.rb', line 25 def self.scrape_leader_2 leader = self.new leader.name = @@page.search("h4")[1].text.split(". ")[1] leader.points = @@page.search("p")[7].text.split("T")[0] leader end |
.scrape_leader_3 ⇒ Object
32 33 34 35 36 37 |
# File 'lib/nba_leader/leader.rb', line 32 def self.scrape_leader_3 leader = self.new leader.name = @@page.search("h4")[2].text.split(". ")[1] leader.points = @@page.search("p")[8].text.split("T")[0] leader end |
.scrape_leader_4 ⇒ Object
39 40 41 42 43 44 |
# File 'lib/nba_leader/leader.rb', line 39 def self.scrape_leader_4 leader = self.new leader.name = @@page.search("h4")[3].text.split(". ")[1] leader.points = @@page.search("p")[9].text.split("T")[0] leader end |
.scrape_leader_5 ⇒ Object
46 47 48 49 50 51 |
# File 'lib/nba_leader/leader.rb', line 46 def self.scrape_leader_5 leader = self.new leader.name = @@page.search("h4")[4].text.split(". ")[1] leader.points = @@page.search("p")[10].text.split("T")[0] leader end |
.scrape_leaders ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/nba_leader/leader.rb', line 4 def self.scrape_leaders leaders = [] leaders << self.scrape_leader_1 leaders << self.scrape_leader_2 leaders << self.scrape_leader_3 leaders << self.scrape_leader_4 leaders << self.scrape_leader_5 leaders end |