Class: Bagel::Graphic::Stats
- Inherits:
-
Object
- Object
- Bagel::Graphic::Stats
- Defined in:
- lib/bagel/graphic/stats.rb
Defined Under Namespace
Classes: Duration, Header, Result, Stat
Constant Summary collapse
- WIDTH =
1440
- HEIGHT =
900
- COLOR_BG =
COLOR_GREY
- FILENAME_SUFFIX =
'-stats'
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#points ⇒ Object
readonly
Returns the value of attribute points.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
-
#initialize(names:, score:, points:) ⇒ Stats
constructor
A new instance of Stats.
- #save ⇒ Object
Constructor Details
#initialize(names:, score:, points:) ⇒ Stats
Returns a new instance of Stats.
12 13 14 15 16 17 18 19 |
# File 'lib/bagel/graphic/stats.rb', line 12 def initialize(names:, score:, points:) @names = names @score = score @points = points @canvas = Image.new(WIDTH, HEIGHT) { |i| i.background_color = COLOR_BG } @offset_y = 0 end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
10 11 12 |
# File 'lib/bagel/graphic/stats.rb', line 10 def names @names end |
#points ⇒ Object (readonly)
Returns the value of attribute points.
10 11 12 |
# File 'lib/bagel/graphic/stats.rb', line 10 def points @points end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
10 11 12 |
# File 'lib/bagel/graphic/stats.rb', line 10 def score @score end |
Instance Method Details
#save ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bagel/graphic/stats.rb', line 21 def save add_header add_result add_duration add_stat(0, Bagel::Tennis::Stats::Aces.new(points)) add_stat(1, Bagel::Tennis::Stats::DoubleFaults.new(points)) add_stat(0, Bagel::Tennis::Stats::FirstServeIn.new(points)) add_stat(1, Bagel::Tennis::Stats::FirstServePointsWon.new(points)) add_stat(0, Bagel::Tennis::Stats::SecondServePointsWon.new(points)) add_stat(1, Bagel::Tennis::Stats::Winners.new(points)) add_stat(0, Bagel::Tennis::Stats::UnforcedErrors.new(points)) add_stat(1, Bagel::Tennis::Stats::NetPointsWon.new(points)) add_stat(0, Bagel::Tennis::Stats::BreakPointsWon.new(points)) add_stat(1, Bagel::Tennis::Stats::PointsWon.new(points)) @canvas.write(path) path end |