Class: ScraperLeague::Game

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Game

Returns a new instance of Game.



657
658
659
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 657

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.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def ats_winner
  @ats_winner
end

#away_teamObject (readonly)

Returns the value of attribute away_team.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def away_team
  @away_team
end

#doubleheaderObject (readonly)

Returns the value of attribute doubleheader.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def doubleheader
  @doubleheader
end

#endingObject (readonly)

Returns the value of attribute ending.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def ending
  @ending
end

#home_teamObject (readonly)

Returns the value of attribute home_team.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def home_team
  @home_team
end

#losing_scoreObject (readonly)

Returns the value of attribute losing_score.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def losing_score
  @losing_score
end

#notesObject (readonly)

Returns the value of attribute notes.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def notes
  @notes
end

#over_under_resultObject (readonly)

Returns the value of attribute over_under_result.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def over_under_result
  @over_under_result
end

#timeObject (readonly)

Returns the value of attribute time.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def time
  @time
end

#vegas_infoObject (readonly)

Returns the value of attribute vegas_info.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def vegas_info
  @vegas_info
end

#winning_scoreObject (readonly)

Returns the value of attribute winning_score.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def winning_score
  @winning_score
end

#winning_teamObject (readonly)

Returns the value of attribute winning_team.



653
654
655
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 653

def winning_team
  @winning_team
end

Instance Method Details

#==(other_game) ⇒ Object



677
678
679
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 677

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



688
689
690
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 688

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



673
674
675
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 673

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

#home_or_away_team(team) ⇒ Object



681
682
683
684
685
686
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 681

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)


669
670
671
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 669

def teams_found?
  home_team && away_team
end

#update(args = {}) ⇒ Object



661
662
663
664
665
666
667
# File 'lib/vegas_insider_scraper/scraper_league.rb', line 661

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