Class: Gameday::Game

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/gameday/game.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#scoreboardObject

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_codeObject



43
44
45
# File 'lib/gameday/game.rb', line 43

def away_code
  self["away_code"]
end

#away_pitcher_nameObject



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

#dayObject



67
68
69
# File 'lib/gameday/game.rb', line 67

def day
  scoreboard.day
end

#get_boxscoreObject



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_boxscoreObject



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_codeObject



47
48
49
# File 'lib/gameday/game.rb', line 47

def home_code
  self["home_code"]
end

#home_pitcher_nameObject



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

#monthObject



64
65
66
# File 'lib/gameday/game.rb', line 64

def month
  scoreboard.month
end

#start_timeObject



15
16
17
# File 'lib/gameday/game.rb', line 15

def start_time
  Time.parse(start_time_string)
end

#start_time_stringObject



19
20
21
# File 'lib/gameday/game.rb', line 19

def start_time_string
  "#{self['time']}#{self['ampm']} #{self['time_zone']}"
end

#yearObject



61
62
63
# File 'lib/gameday/game.rb', line 61

def year
  scoreboard.year
end