Class: HelloTable::BaseballGame
- Inherits:
-
Object
- Object
- HelloTable::BaseballGame
- Includes:
- Glimmer, Glimmer::DataBinding::ObservableModel
- Defined in:
- lib/glimmer-dsl-opal/samples/hello/hello_table.rb
Constant Summary collapse
- TEAM_BALLPARKS =
{ 'Boston Red Sox' => 'Fenway Park', 'Chicago Cubs' => 'Wrigley Field', 'Cincinnati Reds' => 'Great American Ball Park', 'Cleveland Indians' => 'Progressive Field', 'Houston Astros' => 'Minute Maid Park', 'Milwaukee Brewers' => 'Miller Park', 'New York Yankees' => 'Yankee Stadium', 'St Louis Cardinals' => 'Busch Stadium', }
Class Attribute Summary collapse
-
.selected_game ⇒ Object
Returns the value of attribute selected_game.
Instance Attribute Summary collapse
-
#away_team ⇒ Object
Returns the value of attribute away_team.
-
#ballpark ⇒ Object
Returns the value of attribute ballpark.
-
#date_time ⇒ Object
Returns the value of attribute date_time.
-
#home_team ⇒ Object
Returns the value of attribute home_team.
-
#promotion ⇒ Object
Returns the value of attribute promotion.
Class Method Summary collapse
- .all_playoff_games ⇒ Object
- .playoff_type ⇒ Object
- .playoff_type=(new_playoff_type) ⇒ Object
- .playoff_type_options ⇒ Object
- .schedule ⇒ Object
- .schedule=(new_schedule) ⇒ Object
Instance Method Summary collapse
- #away_team_options ⇒ Object
- #ballpark_options ⇒ Object
- #book! ⇒ Object
- #date ⇒ Object
- #game_date ⇒ Object
- #game_time ⇒ Object
- #home_team_options ⇒ Object
-
#initialize(date_time, home_team, away_team, promotion = 'N/A') ⇒ BaseballGame
constructor
A new instance of BaseballGame.
- #time ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(date_time, home_team, away_team, promotion = 'N/A') ⇒ BaseballGame
Returns a new instance of BaseballGame.
121 122 123 124 125 126 127 128 129 130 |
# 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 |
Class Attribute Details
.selected_game ⇒ Object
Returns the value of attribute selected_game.
25 26 27 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 25 def selected_game @selected_game end |
Instance Attribute Details
#away_team ⇒ Object
Returns the value of attribute away_team.
119 120 121 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 119 def away_team @away_team end |
#ballpark ⇒ Object
Returns the value of attribute ballpark.
119 120 121 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 119 def ballpark @ballpark end |
#date_time ⇒ Object
Returns the value of attribute date_time.
119 120 121 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 119 def date_time @date_time end |
#home_team ⇒ Object
Returns the value of attribute home_team.
119 120 121 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 119 def home_team @home_team end |
#promotion ⇒ Object
Returns the value of attribute promotion.
119 120 121 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 119 def promotion @promotion end |
Class Method Details
.all_playoff_games ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# 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 |
.playoff_type ⇒ Object
83 84 85 |
# 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) ⇒ Object
87 88 89 90 |
# 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 ⇒ Object
92 93 94 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 92 def all_playoff_games.keys end |
.schedule ⇒ Object
96 97 98 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 96 def schedule @schedule ||= all_playoff_games[playoff_type] end |
.schedule=(new_schedule) ⇒ Object
100 101 102 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 100 def schedule=(new_schedule) @schedule = new_schedule end |
Instance Method Details
#away_team_options ⇒ Object
165 166 167 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 165 def TEAM_BALLPARKS.keys end |
#ballpark_options ⇒ Object
169 170 171 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 169 def [TEAM_BALLPARKS[@home_team], TEAM_BALLPARKS[@away_team]] end |
#book! ⇒ Object
177 178 179 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 177 def book! "Thank you for booking #{to_s}" end |
#date ⇒ Object
145 146 147 |
# 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 ⇒ Object
153 154 155 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 153 def game_date date_time.strftime("%m/%d/%Y") end |
#game_time ⇒ Object
157 158 159 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 157 def game_time date_time.strftime("%I:%M %p") end |
#home_team_options ⇒ Object
161 162 163 |
# File 'lib/glimmer-dsl-opal/samples/hello/hello_table.rb', line 161 def TEAM_BALLPARKS.keys end |
#time ⇒ Object
149 150 151 |
# 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 ⇒ Object
173 174 175 |
# 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 |