Class: ScraperLeague::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/sports/scraper_league.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Game

Returns a new instance of Game.



647
648
649
# File 'lib/sports/scraper_league.rb', line 647

def initialize(args = {})
  Game.sanitize(args).map { |attribute, value| instance_variable_set("@#{attribute}", value) }
end

Instance Attribute Details

#ats_winnerObject (readonly)

Returns the value of attribute ats_winner.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def ats_winner
  @ats_winner
end

#away_teamObject (readonly)

Returns the value of attribute away_team.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def away_team
  @away_team
end

#doubleheaderObject (readonly)

Returns the value of attribute doubleheader.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def doubleheader
  @doubleheader
end

#endingObject (readonly)

Returns the value of attribute ending.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def ending
  @ending
end

#home_teamObject (readonly)

Returns the value of attribute home_team.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def home_team
  @home_team
end

#losing_scoreObject (readonly)

Returns the value of attribute losing_score.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def losing_score
  @losing_score
end

#notesObject (readonly)

Returns the value of attribute notes.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def notes
  @notes
end

#over_under_resultObject (readonly)

Returns the value of attribute over_under_result.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def over_under_result
  @over_under_result
end

#timeObject (readonly)

Returns the value of attribute time.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def time
  @time
end

#vegas_infoObject (readonly)

Returns the value of attribute vegas_info.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def vegas_info
  @vegas_info
end

#winning_scoreObject (readonly)

Returns the value of attribute winning_score.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def winning_score
  @winning_score
end

#winning_teamObject (readonly)

Returns the value of attribute winning_team.



644
645
646
# File 'lib/sports/scraper_league.rb', line 644

def winning_team
  @winning_team
end

Instance Method Details

#==(other_game) ⇒ Object



667
668
669
# File 'lib/sports/scraper_league.rb', line 667

def ==(other_game)
  home_team == other_game.home_team && away_team == other_game.away_team && time.to_date == other_game.time.to_date && doubleheader == other_game.doubleheader
end

#as_jsonObject



678
679
680
# File 'lib/sports/scraper_league.rb', line 678

def as_json
  instance_variables.each_with_object({}) { |var, hash| hash[var.to_s.delete("@").to_sym] = instance_variable_get(var) }
end

#find_equal(games) ⇒ Object



663
664
665
# File 'lib/sports/scraper_league.rb', line 663

def find_equal(games)
  games.detect { |g| g == self }
end

#home_or_away_team(team) ⇒ Object



671
672
673
674
675
676
# File 'lib/sports/scraper_league.rb', line 671

def home_or_away_team(team)
  case team
  when home_team then :home
  when away_team then :away
  else nil end
end

#teams_found?Boolean

Returns:

  • (Boolean)


659
660
661
# File 'lib/sports/scraper_league.rb', line 659

def teams_found?
  home_team && away_team
end

#update(args = {}) ⇒ Object



651
652
653
654
655
656
657
# File 'lib/sports/scraper_league.rb', line 651

def update(args = {})
  Game.sanitize(args).map { |attribute, value| 
    new_val = (attribute == :vegas_info && value && vegas_info) ? value.merge(vegas_info) : value
    instance_variable_set("@#{attribute}", new_val)
  }
  return self
end