lib/sportdb/formats/goals.rb in sportdb-formats-1.1.6 vs lib/sportdb/formats/goals.rb in sportdb-formats-1.2.0

- old
+ new

@@ -1,6 +1,5 @@ -# encoding: utf-8 module SportDb @@ -13,10 +12,19 @@ attr_accessor :minutes # ary of minutes e.g. 30', 45+2', 72' def initialize @minutes = [] end + + def pretty_print( printer ) + buf = String.new + buf << "<GoalsPlayerStruct: #{@name} " + buf << @minutes.pretty_print_inspect + buf << ">" + + printer.text( buf ) + end end class GoalsMinuteStruct attr_accessor :minute, :offset @@ -25,10 +33,22 @@ def initialize @offset = 0 @penalty = false @owngoal = false end + + def pretty_print( printer ) + buf = String.new + buf << "<GoalsMinuteStruct: #{@minute}" + buf << "+#{@offset}" if @offset && @offset > 0 + buf << "'" + buf << " (o.g.)" if @owngoal + buf << " (pen.)" if @penalty + buf << ">" + + printer.text( buf ) + end end class GoalStruct ###### @@ -57,9 +77,25 @@ end def state [@name, @team, @minute, @offset, @penalty, @owngoal, @score1, @score2] end + + + def pretty_print( printer ) + buf = String.new + buf << "<GoalStruct: #{@score1}-#{@score2} #{@name} #{@minute}" + buf << "+#{@offset}" if @offset && @offset > 0 + buf << "'" + buf << " (o.g.)" if @owngoal + buf << " (pen.)" if @penalty + buf << " for #{@team}" ### team 1 or 2 - use home/away + buf << ">" + + printer.text( buf ) + end + + end # todo: find a better name? to avoid confusing w/ GoalsParser? use MatchGoalsParser or similar?