Class: Gameday::Game
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Gameday::Game
- Defined in:
- lib/gameday/game.rb
Instance Attribute Summary collapse
-
#scoreboard ⇒ Object
Returns the value of attribute scoreboard.
Class Method Summary collapse
Instance Method Summary collapse
- #__getobj__ ⇒ Object
- #away_code ⇒ Object
- #away_pitcher_name ⇒ Object
- #day ⇒ Object
- #get_boxscore ⇒ Object
- #get_previous_day_boxscore ⇒ Object
- #home_code ⇒ Object
- #home_pitcher_name ⇒ Object
-
#initialize(game_obj, scoreboard) ⇒ Game
constructor
A new instance of Game.
- #month ⇒ Object
- #start_time ⇒ Object
- #start_time_string ⇒ Object
- #year ⇒ Object
Constructor Details
#initialize(game_obj, scoreboard) ⇒ Game
Returns a new instance of Game.
10 11 12 13 |
# File 'lib/gameday/game.rb', line 10 def initialize(game_obj, scoreboard) @game = game_obj @scoreboard = scoreboard end |
Instance Attribute Details
#scoreboard ⇒ Object
Returns the value of attribute scoreboard.
4 5 6 |
# File 'lib/gameday/game.rb', line 4 def scoreboard @scoreboard end |
Class Method Details
.get_previous_day(year, month, day) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/gameday/game.rb', line 33 def self.get_previous_day(year,month,day) now = Date.new(year.to_i, month.to_i, day.to_i) day_before = now - 1 { year: "%04d" % day_before.year.to_s, month: "%02d" % day_before.month.to_s, day: "%02d" % day_before.day.to_s } end |
Instance Method Details
#__getobj__ ⇒ Object
6 7 8 |
# File 'lib/gameday/game.rb', line 6 def __getobj__ @game end |
#away_code ⇒ Object
43 44 45 |
# File 'lib/gameday/game.rb', line 43 def away_code self["away_code"] end |
#away_pitcher_name ⇒ Object
56 57 58 59 |
# File 'lib/gameday/game.rb', line 56 def away_pitcher_name return "" unless self["away_probable_pitcher"] Gameday::Pitcher.new(self["away_probable_pitcher"]).name end |
#day ⇒ Object
67 68 69 |
# File 'lib/gameday/game.rb', line 67 def day scoreboard.day end |
#get_boxscore ⇒ Object
23 24 25 |
# File 'lib/gameday/game.rb', line 23 def get_boxscore Gameday::BoxScore.from_params(year,month,day,away_code,home_code) end |
#get_previous_day_boxscore ⇒ Object
27 28 29 30 31 |
# File 'lib/gameday/game.rb', line 27 def get_previous_day_boxscore previous = Gameday::Game.get_previous_day(year,month,day) Gameday::BoxScore.from_params(previous[:year],previous[:month],previous[:day],away_code,home_code) end |
#home_code ⇒ Object
47 48 49 |
# File 'lib/gameday/game.rb', line 47 def home_code self["home_code"] end |
#home_pitcher_name ⇒ Object
51 52 53 54 |
# File 'lib/gameday/game.rb', line 51 def home_pitcher_name return "" unless self["home_probable_pitcher"] Gameday::Pitcher.new(self["home_probable_pitcher"]).name end |
#month ⇒ Object
64 65 66 |
# File 'lib/gameday/game.rb', line 64 def month scoreboard.month end |
#start_time ⇒ Object
15 16 17 |
# File 'lib/gameday/game.rb', line 15 def start_time Time.parse(start_time_string) end |
#start_time_string ⇒ Object
19 20 21 |
# File 'lib/gameday/game.rb', line 19 def start_time_string "#{self['time']}#{self['ampm']} #{self['time_zone']}" end |
#year ⇒ Object
61 62 63 |
# File 'lib/gameday/game.rb', line 61 def year scoreboard.year end |