Class: SportDb::MatchTree::Goal
- Inherits:
-
Object
- Object
- SportDb::MatchTree::Goal
- Defined in:
- lib/sportdb/quick/match_tree/goal.rb
Overview
nested (non-freestanding) inside match (match is parent)
Instance Attribute Summary collapse
-
#minute ⇒ Object
readonly
note - 1|2 expected.
-
#offset ⇒ Object
readonly
note - 1|2 expected.
-
#owngoal ⇒ Object
readonly
note - 1|2 expected.
-
#penalty ⇒ Object
readonly
note - 1|2 expected.
-
#player ⇒ Object
(also: #name)
readonly
note - 1|2 expected.
-
#team ⇒ Object
readonly
note - 1|2 expected.
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#initialize(team:, player:, minute:, offset: nil, owngoal: false, penalty: false) ⇒ Goal
constructor
note: make score1,score2 optional for now !!!!.
- #owngoal? ⇒ Boolean
- #penalty? ⇒ Boolean
- #pretty_print(printer) ⇒ Object
- #state ⇒ Object
- #team1? ⇒ Boolean
- #team2? ⇒ Boolean
Constructor Details
#initialize(team:, player:, minute:, offset: nil, owngoal: false, penalty: false) ⇒ Goal
note: make score1,score2 optional for now !!!!
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 25 def initialize( team:, player:, minute:, offset: nil, owngoal: false, penalty: false ) @team = team # 1|2 @player = player @minute = minute @offset = offset @owngoal = owngoal @penalty = penalty end |
Instance Attribute Details
#minute ⇒ Object (readonly)
note - 1|2 expected
7 8 9 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 7 def minute @minute end |
#offset ⇒ Object (readonly)
note - 1|2 expected
7 8 9 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 7 def offset @offset end |
#owngoal ⇒ Object (readonly)
note - 1|2 expected
7 8 9 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 7 def owngoal @owngoal end |
#penalty ⇒ Object (readonly)
note - 1|2 expected
7 8 9 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 7 def penalty @penalty end |
#player ⇒ Object (readonly) Also known as: name
note - 1|2 expected
7 8 9 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 7 def player @player end |
#team ⇒ Object (readonly)
note - 1|2 expected
7 8 9 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 7 def team @team end |
Instance Method Details
#==(o) ⇒ Object
46 47 48 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 46 def ==(o) o.class == self.class && o.state == state end |
#owngoal? ⇒ Boolean
18 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 18 def owngoal?() @owngoal==true; end |
#penalty? ⇒ Boolean
19 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 19 def penalty?() @penalty==true; end |
#pretty_print(printer) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 50 def pretty_print( printer ) buf = String.new buf << "<Goal" buf << " #{@player} #{@minute}" buf << "+#{@offset}" if @offset && @offset > 0 buf << "'" buf << " (og)" if @owngoal buf << " (p)" if @penalty buf << " for #{@team}" ### team 1 or 2 - use home/away buf << ">" printer.text( buf ) end |
#state ⇒ Object
40 41 42 43 44 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 40 def state [@team, @player, @minute, @offset, @owngoal, @penalty ] end |
#team1? ⇒ Boolean
20 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 20 def team1?() @team == 1; end |
#team2? ⇒ Boolean
21 |
# File 'lib/sportdb/quick/match_tree/goal.rb', line 21 def team2?() @team == 2; end |