Stylize the tournament table.
This commit is contained in:
parent
5ae407f691
commit
0797a62246
@ -33,6 +33,7 @@ module LORChess
|
|||||||
|
|
||||||
fill
|
fill
|
||||||
calculate
|
calculate
|
||||||
|
stylize_table
|
||||||
|
|
||||||
# Clean the vacancy place
|
# Clean the vacancy place
|
||||||
index = @player_pos['Kasparov']
|
index = @player_pos['Kasparov']
|
||||||
@ -63,11 +64,33 @@ module LORChess
|
|||||||
@results.each do |row|
|
@results.each do |row|
|
||||||
sum = 0.0
|
sum = 0.0
|
||||||
row.each { |score| sum += score.to_f }
|
row.each { |score| sum += score.to_f }
|
||||||
sum = sum.to_i if sum == sum.to_i # remove the fractional part if possible
|
|
||||||
@player_score << sum.to_s
|
@player_score << sum.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stylize_table
|
||||||
|
for row in 0..(@dim-1)
|
||||||
|
for cell in 0..(@dim-1)
|
||||||
|
@results[row][cell] = stylize_score @results[row][cell]
|
||||||
|
end
|
||||||
|
|
||||||
|
@player_score[row] = stylize_score @player_score[row]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Replace the fractional part `0.5' by ½
|
||||||
|
def stylize_score score
|
||||||
|
frac = score.split '.'
|
||||||
|
return '' if frac[0].nil?
|
||||||
|
unless frac[0] == '0'
|
||||||
|
score = frac[0]
|
||||||
|
score += '½' if frac[1] == '5'
|
||||||
|
else
|
||||||
|
score = (frac[1] == '5') ? '½' : '0'
|
||||||
|
end
|
||||||
|
score
|
||||||
|
end
|
||||||
|
|
||||||
def to_html
|
def to_html
|
||||||
|
|
||||||
@buffer << "<table class=\"table table-bordered tournament\">\n"
|
@buffer << "<table class=\"table table-bordered tournament\">\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user