class HelloTable::BaseballGame

Constants

TEAM_BALLPARKS

Attributes

selected_game[RW]
away_team[RW]
ballpark[RW]
date_time[RW]
home_team[RW]
promotion[RW]

Public Class Methods

all_playoff_games() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 27
def all_playoff_games
  @all_playoff_games ||= {
    'NLDS' => [
      new(Time.new(2037, 10, 6, 12, 0),  'Chicago Cubs', 'Milwaukee Brewers', 'Free Bobblehead'),
      new(Time.new(2037, 10, 7, 12, 0),  'Chicago Cubs', 'Milwaukee Brewers'),
      new(Time.new(2037, 10, 8, 12, 0),  'Milwaukee Brewers', 'Chicago Cubs'),
      new(Time.new(2037, 10, 9, 12, 0),  'Milwaukee Brewers', 'Chicago Cubs'),
      new(Time.new(2037, 10, 10, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs', 'Free Umbrella'),
      new(Time.new(2037, 10, 6, 18, 0),  'Cincinnati Reds', 'St Louis Cardinals', 'Free Bobblehead'),
      new(Time.new(2037, 10, 7, 18, 0),  'Cincinnati Reds', 'St Louis Cardinals'),
      new(Time.new(2037, 10, 8, 18, 0),  'St Louis Cardinals', 'Cincinnati Reds'),
      new(Time.new(2037, 10, 9, 18, 0),  'St Louis Cardinals', 'Cincinnati Reds'),
      new(Time.new(2037, 10, 10, 18, 0), 'St Louis Cardinals', 'Cincinnati Reds', 'Free Umbrella'),
    ],
    'ALDS' => [
      new(Time.new(2037, 10, 6, 12, 0),  'New York Yankees', 'Boston Red Sox', 'Free Bobblehead'),
      new(Time.new(2037, 10, 7, 12, 0),  'New York Yankees', 'Boston Red Sox'),
      new(Time.new(2037, 10, 8, 12, 0),  'Boston Red Sox', 'New York Yankees'),
      new(Time.new(2037, 10, 9, 12, 0),  'Boston Red Sox', 'New York Yankees'),
      new(Time.new(2037, 10, 10, 12, 0), 'Boston Red Sox', 'New York Yankees', 'Free Umbrella'),
      new(Time.new(2037, 10, 6, 18, 0),  'Houston Astros', 'Cleveland Indians', 'Free Bobblehead'),
      new(Time.new(2037, 10, 7, 18, 0),  'Houston Astros', 'Cleveland Indians'),
      new(Time.new(2037, 10, 8, 18, 0),  'Cleveland Indians', 'Houston Astros'),
      new(Time.new(2037, 10, 9, 18, 0),  'Cleveland Indians', 'Houston Astros'),
      new(Time.new(2037, 10, 10, 18, 0), 'Cleveland Indians', 'Houston Astros', 'Free Umbrella'),
    ],
    'NLCS' => [
      new(Time.new(2037, 10, 12, 12, 0), 'Chicago Cubs', 'Cincinnati Reds', 'Free Towel'),
      new(Time.new(2037, 10, 13, 12, 0), 'Chicago Cubs', 'Cincinnati Reds'),
      new(Time.new(2037, 10, 14, 12, 0), 'Cincinnati Reds', 'Chicago Cubs'),
      new(Time.new(2037, 10, 15, 18, 0), 'Cincinnati Reds', 'Chicago Cubs'),
      new(Time.new(2037, 10, 16, 18, 0), 'Cincinnati Reds', 'Chicago Cubs'),
      new(Time.new(2037, 10, 17, 18, 0), 'Chicago Cubs', 'Cincinnati Reds'),
      new(Time.new(2037, 10, 18, 12, 0), 'Chicago Cubs', 'Cincinnati Reds', 'Free Poncho'),
    ],
    'ALCS' => [
      new(Time.new(2037, 10, 12, 12, 0), 'Houston Astros', 'Boston Red Sox', 'Free Towel'),
      new(Time.new(2037, 10, 13, 12, 0), 'Houston Astros', 'Boston Red Sox'),
      new(Time.new(2037, 10, 14, 12, 0), 'Boston Red Sox', 'Houston Astros'),
      new(Time.new(2037, 10, 15, 18, 0), 'Boston Red Sox', 'Houston Astros'),
      new(Time.new(2037, 10, 16, 18, 0), 'Boston Red Sox', 'Houston Astros'),
      new(Time.new(2037, 10, 17, 18, 0), 'Houston Astros', 'Boston Red Sox'),
      new(Time.new(2037, 10, 18, 12, 0), 'Houston Astros', 'Boston Red Sox', 'Free Poncho'),
    ],
    'World Series' => [
      new(Time.new(2037, 10, 20, 18, 0), 'Chicago Cubs', 'Boston Red Sox', 'Free Baseball Cap'),
      new(Time.new(2037, 10, 21, 18, 0), 'Chicago Cubs', 'Boston Red Sox'),
      new(Time.new(2037, 10, 22, 18, 0), 'Boston Red Sox', 'Chicago Cubs'),
      new(Time.new(2037, 10, 23, 18, 0), 'Boston Red Sox', 'Chicago Cubs'),
      new(Time.new(2037, 10, 24, 18, 0), 'Boston Red Sox', 'Chicago Cubs'),
      new(Time.new(2037, 10, 25, 18, 0), 'Chicago Cubs', 'Boston Red Sox'),
      new(Time.new(2037, 10, 26, 18, 0), 'Chicago Cubs', 'Boston Red Sox', 'Free World Series Polo'),
    ]
  }
end
new(date_time, home_team, away_team, promotion = 'N/A') click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 121
def initialize(date_time, home_team, away_team, promotion = 'N/A')
  self.date_time = date_time
  self.home_team = home_team
  self.away_team = away_team
  self.promotion = promotion
  observe(self, :date_time) do |new_value|
    notify_observers(:game_date)
    notify_observers(:game_time)
  end
end
playoff_type() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 83
def playoff_type
  @playoff_type ||= 'World Series'
end
playoff_type=(new_playoff_type) click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 87
def playoff_type=(new_playoff_type)
  @playoff_type = new_playoff_type
  self.schedule=(all_playoff_games[@playoff_type])
end
playoff_type_options() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 92
def playoff_type_options
  all_playoff_games.keys
end
schedule() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 96
def schedule
  @schedule ||= all_playoff_games[playoff_type]
end
schedule=(new_schedule) click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 100
def schedule=(new_schedule)
  @schedule = new_schedule
end

Public Instance Methods

away_team=(away_team_value) click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 139
def away_team=(away_team_value)
  if away_team_value != home_team
    @away_team = away_team_value
  end
end
away_team_options() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 165
def away_team_options
  TEAM_BALLPARKS.keys
end
ballpark_options() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 169
def ballpark_options
  [TEAM_BALLPARKS[@home_team], TEAM_BALLPARKS[@away_team]]
end
book!() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 177
def book!
  "Thank you for booking #{to_s}"
end
date() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 145
def date
  Date.new(date_time.year, date_time.month, date_time.day)
end
game_date() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 153
def game_date
  date_time.strftime("%m/%d/%Y")
end
game_time() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 157
def game_time
  date_time.strftime("%I:%M %p")
end
home_team=(home_team_value) click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 132
def home_team=(home_team_value)
  if home_team_value != away_team
    @home_team = home_team_value
    self.ballpark = TEAM_BALLPARKS[@home_team]
  end
end
home_team_options() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 161
def home_team_options
  TEAM_BALLPARKS.keys
end
time() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 149
def time
  Time.new(0, 1, 1, date_time.hour, date_time.min, date_time.sec, '+00:00')
end
to_s() click to toggle source
# File lib/glimmer-dsl-opal/samples/hello/hello_table.rb, line 173
def to_s
  "#{home_team} vs #{away_team} at #{ballpark} on #{game_date} #{game_time}"
end