class Stattleship::Models::Game
Public Instance Methods
away_team_colors()
click to toggle source
# File lib/stattleship/models/game.rb, line 35 def away_team_colors if away_team away_team.colors end end
away_team_name()
click to toggle source
# File lib/stattleship/models/game.rb, line 41 def away_team_name if away_team away_team.name end end
away_team_slug()
click to toggle source
# File lib/stattleship/models/game.rb, line 47 def away_team_slug if away_team away_team.slug end end
baseball?()
click to toggle source
# File lib/stattleship/models/game.rb, line 142 def baseball? league.baseball? end
basketball?()
click to toggle source
# File lib/stattleship/models/game.rb, line 146 def basketball? league.basketball? end
city()
click to toggle source
# File lib/stattleship/models/game.rb, line 4 def city if venue venue.city end end
colors()
click to toggle source
# File lib/stattleship/models/game.rb, line 10 def colors [away_team_colors, home_team_colors]. flatten. compact. uniq end
coordinates()
click to toggle source
# File lib/stattleship/models/game.rb, line 188 def coordinates [latitude, longitude] end
dump()
click to toggle source
# File lib/stattleship/models/game.rb, line 255 def dump { at_neutral_site: at_neutral_site, away_team_colors: away_team_colors, away_team_name: away_team_name, away_team_outcome: away_team_outcome, away_team_slug: away_team_slug, city: city, colors: colors, coordinates: coordinates, daytime: daytime, home_team_colors: home_team_colors, home_team_name: home_team_name, home_team_outcome: home_team_outcome, home_team_slug: home_team_slug, interval: interval, interval_type: interval_type, label: label, latitude: latitude, longitude: longitude, league_abbreviation: league_abbreviation, league_name: league_name, losing_score: losing_score, losing_scoreline: losing_scoreline, losing_team_colors: losing_team_colors, losing_team_score: losing_team_score, losing_team_slug: losing_team_slug, losing_team: losing_team.hash, name: name, on: on, score: score, scoreline: scoreline, sentence: to_sentence, short_date: short_date, slug: slug, sport: sport, state: state, status: status, team_slugs: team_slugs, temperature_unit: temperature_unit, title: title, venue_capacity: venue_capacity, venue_name: venue_name, venue_slug: venue_slug, weather_conditions: weather_conditions, wind_direction: wind_direction, wind_speed: wind_speed, wind_speed_unit: wind_speed_unit, winning_score: winning_score, winning_scoreline: winning_scoreline, winning_team_colors: winning_team_colors, winning_team_name: winning_team_name, winning_team_score: winning_team_score, winning_team_slug: winning_team_slug, winning_team: winning_team_hash, } end
football?()
click to toggle source
# File lib/stattleship/models/game.rb, line 150 def football? league.football? end
game_clock()
click to toggle source
# File lib/stattleship/models/game.rb, line 243 def game_clock if sport == 'baseball' "#{top_or_bottom} #{period.ordinalize} #{period_label}" else "#{clock} #{period.ordinalize} #{period_label}" end end
hockey?()
click to toggle source
# File lib/stattleship/models/game.rb, line 138 def hockey? league.hockey? end
home_team_colors()
click to toggle source
# File lib/stattleship/models/game.rb, line 53 def home_team_colors if home_team home_team.colors end end
home_team_name()
click to toggle source
# File lib/stattleship/models/game.rb, line 59 def home_team_name if home_team home_team.name end end
home_team_slug()
click to toggle source
# File lib/stattleship/models/game.rb, line 65 def home_team_slug if home_team home_team.slug end end
latitude()
click to toggle source
# File lib/stattleship/models/game.rb, line 176 def latitude if venue venue.latitude end end
league_abbreviation()
click to toggle source
# File lib/stattleship/models/game.rb, line 29 def league_abbreviation if league league.abbreviation end end
league_name()
click to toggle source
# File lib/stattleship/models/game.rb, line 23 def league_name if league league.name end end
longitude()
click to toggle source
# File lib/stattleship/models/game.rb, line 182 def longitude if venue venue.longitude end end
losing_score()
click to toggle source
# File lib/stattleship/models/game.rb, line 192 def losing_score if score score.split('-'). map(&:to_i). sort. join('-') end end
losing_scoreline()
click to toggle source
# File lib/stattleship/models/game.rb, line 227 def losing_scoreline if winning_team && losing_team "#{losing_team.nickname} #{losing_team_score} - #{winning_team.nickname} #{winning_team_score}" else '' end end
losing_team()
click to toggle source
# File lib/stattleship/models/game.rb, line 118 def losing_team if home_team_slug == winning_team_slug away_team else home_team end end
losing_team_colors()
click to toggle source
# File lib/stattleship/models/game.rb, line 112 def losing_team_colors if losing_team losing_team.colors end end
losing_team_hash()
click to toggle source
# File lib/stattleship/models/game.rb, line 106 def losing_team_hash if losing_team losing_team.dump end end
losing_team_name()
click to toggle source
# File lib/stattleship/models/game.rb, line 126 def losing_team_name if losing_team losing_team.name end end
losing_team_score()
click to toggle source
# File lib/stattleship/models/game.rb, line 215 def losing_team_score [away_team_score, home_team_score].min end
losing_team_slug()
click to toggle source
# File lib/stattleship/models/game.rb, line 132 def losing_team_slug if losing_team losing_team.slug end end
short_date()
click to toggle source
# File lib/stattleship/models/game.rb, line 154 def short_date started_at.strftime('%m/%d/%y') end
sport()
click to toggle source
# File lib/stattleship/models/game.rb, line 17 def sport if league league.sport end end
state()
click to toggle source
# File lib/stattleship/models/game.rb, line 71 def state if venue venue.state end end
team_slugs()
click to toggle source
# File lib/stattleship/models/game.rb, line 77 def team_slugs [away_team_slug, home_team_slug].compact end
to_sentence()
click to toggle source
# File lib/stattleship/models/game.rb, line 251 def to_sentence "#{winning_team_name} won #{winning_score} on #{short_date}" end
top_or_bottom()
click to toggle source
# File lib/stattleship/models/game.rb, line 235 def top_or_bottom if clock == ':30' 'Bottom' else 'Top' end end
venue_capacity()
click to toggle source
# File lib/stattleship/models/game.rb, line 158 def venue_capacity if venue venue.capacity end end
venue_name()
click to toggle source
# File lib/stattleship/models/game.rb, line 164 def venue_name if venue venue.name end end
venue_slug()
click to toggle source
# File lib/stattleship/models/game.rb, line 170 def venue_slug if venue venue.slug end end
winning_score()
click to toggle source
# File lib/stattleship/models/game.rb, line 201 def winning_score if score score.split('-'). map(&:to_i). sort. reverse. join('-') end end
winning_scoreline()
click to toggle source
# File lib/stattleship/models/game.rb, line 219 def winning_scoreline if winning_team && losing_team "#{winning_team.nickname} #{winning_team_score} - #{losing_team.nickname} #{losing_team_score}" else '' end end
winning_team_colors()
click to toggle source
# File lib/stattleship/models/game.rb, line 82 def winning_team_colors if winning_team winning_team.colors end end
winning_team_hash()
click to toggle source
# File lib/stattleship/models/game.rb, line 100 def winning_team_hash if winning_team winning_team.dump end end
winning_team_name()
click to toggle source
# File lib/stattleship/models/game.rb, line 88 def winning_team_name if winning_team winning_team.name end end
winning_team_score()
click to toggle source
# File lib/stattleship/models/game.rb, line 211 def winning_team_score [away_team_score, home_team_score].max end
winning_team_slug()
click to toggle source
# File lib/stattleship/models/game.rb, line 94 def winning_team_slug if winning_team winning_team.slug end end