Class: Npb::Schedule
- Inherits:
-
Object
- Object
- Npb::Schedule
- Defined in:
- lib/npb/schedule.rb
Instance Attribute Summary collapse
-
#home_score ⇒ Object
Returns the value of attribute home_score.
-
#home_team ⇒ Object
Returns the value of attribute home_team.
-
#stadium ⇒ Object
Returns the value of attribute stadium.
-
#start_at ⇒ Object
Returns the value of attribute start_at.
-
#visitor_score ⇒ Object
Returns the value of attribute visitor_score.
-
#visitor_team ⇒ Object
Returns the value of attribute visitor_team.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(home_team: nil, visitor_team: nil, home_score: nil, visitor_score: nil, stadium: nil, start_at: nil) ⇒ Schedule
constructor
A new instance of Schedule.
Constructor Details
#initialize(home_team: nil, visitor_team: nil, home_score: nil, visitor_score: nil, stadium: nil, start_at: nil) ⇒ Schedule
Returns a new instance of Schedule.
75 76 77 78 79 80 81 82 |
# File 'lib/npb/schedule.rb', line 75 def initialize(home_team: nil, visitor_team: nil, home_score: nil, visitor_score: nil, stadium: nil, start_at: nil) @home_team = home_team @visitor_team = visitor_team @home_score = home_score @visitor_score = visitor_score @stadium = stadium @start_at = start_at end |
Instance Attribute Details
#home_score ⇒ Object
Returns the value of attribute home_score.
8 9 10 |
# File 'lib/npb/schedule.rb', line 8 def home_score @home_score end |
#home_team ⇒ Object
Returns the value of attribute home_team.
8 9 10 |
# File 'lib/npb/schedule.rb', line 8 def home_team @home_team end |
#stadium ⇒ Object
Returns the value of attribute stadium.
8 9 10 |
# File 'lib/npb/schedule.rb', line 8 def stadium @stadium end |
#start_at ⇒ Object
Returns the value of attribute start_at.
8 9 10 |
# File 'lib/npb/schedule.rb', line 8 def start_at @start_at end |
#visitor_score ⇒ Object
Returns the value of attribute visitor_score.
8 9 10 |
# File 'lib/npb/schedule.rb', line 8 def visitor_score @visitor_score end |
#visitor_team ⇒ Object
Returns the value of attribute visitor_team.
8 9 10 |
# File 'lib/npb/schedule.rb', line 8 def visitor_team @visitor_team end |
Class Method Details
.all ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/npb/schedule.rb', line 11 def all first_days_of_week.each_with_object([]) do |first_day_of_week, arr| puts "processing #{first_day_of_week}" sources(first_day_of_week: first_day_of_week).each do |source| next if source.css('td').text.include?('試合はありません') @date = source.css('th').text if source.css('th').present? @time = source.css('td.pl7')[2].text.split[0] @score = source.css('td.ct')[0].text arr << new( home_team: source.css('td.pl7')[0].text, visitor_team: source.css('td.pl7')[1].text, home_score: home_score, visitor_score: visitor_score, stadium: source.css('td.pl7')[2].text.split[1], start_at: Time.new(2015, month, day, hour, minute) ) end end end |