Class: InOrOut::Match
- Inherits:
-
Object
- Object
- InOrOut::Match
- Defined in:
- lib/in_or_out/models/match.rb
Instance Attribute Summary collapse
-
#players ⇒ Object
readonly
Returns the value of attribute players.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #find_player(player_name, team_name) ⇒ Object
-
#initialize(home_team, round, away_team = nil) ⇒ Match
constructor
A new instance of Match.
Constructor Details
#initialize(home_team, round, away_team = nil) ⇒ Match
Returns a new instance of Match.
10 11 12 13 14 |
# File 'lib/in_or_out/models/match.rb', line 10 def initialize(home_team, round, away_team = nil) @home_team, @away_team, @round = home_team, away_team, round @players = InOrOut::PlayerExtractor.new(download_match_data).extract @players.empty? ? @status = 'pending' : @status = 'ready' end |
Instance Attribute Details
#players ⇒ Object (readonly)
Returns the value of attribute players.
8 9 10 |
# File 'lib/in_or_out/models/match.rb', line 8 def players @players end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/in_or_out/models/match.rb', line 8 def status @status end |
Class Method Details
.find(**options) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/in_or_out/models/match.rb', line 20 def self.find(**) match = AFL::Schedule.new.next_match([:team]) if match self.new(match[:home_team], match[:round], match[:away_team]) else match end end |
Instance Method Details
#find_player(player_name, team_name) ⇒ Object
16 17 18 |
# File 'lib/in_or_out/models/match.rb', line 16 def find_player(player_name, team_name) @players.detect { |player| player.name == player_name && player.team == team_name } end |