Class: SportDb::MatchTree::Goal

Inherits:
Object
  • Object
show all
Defined in:
lib/sportdb/quick/match_tree/goal.rb

Overview

nested (non-freestanding) inside match (match is parent)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#minuteObject (readonly)

note - 1|2 expected



7
8
9
# File 'lib/sportdb/quick/match_tree/goal.rb', line 7

def minute
  @minute
end

#offsetObject (readonly)

note - 1|2 expected



7
8
9
# File 'lib/sportdb/quick/match_tree/goal.rb', line 7

def offset
  @offset
end

#owngoalObject (readonly)

note - 1|2 expected



7
8
9
# File 'lib/sportdb/quick/match_tree/goal.rb', line 7

def owngoal
  @owngoal
end

#penaltyObject (readonly)

note - 1|2 expected



7
8
9
# File 'lib/sportdb/quick/match_tree/goal.rb', line 7

def penalty
  @penalty
end

#playerObject (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

#teamObject (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

Returns:

  • (Boolean)


18
# File 'lib/sportdb/quick/match_tree/goal.rb', line 18

def owngoal?() @owngoal==true; end

#penalty?Boolean

Returns:

  • (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

#stateObject



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

Returns:

  • (Boolean)


20
# File 'lib/sportdb/quick/match_tree/goal.rb', line 20

def team1?()   @team == 1; end

#team2?Boolean

Returns:

  • (Boolean)


21
# File 'lib/sportdb/quick/match_tree/goal.rb', line 21

def team2?()   @team == 2; end