Class: AocCli::Presenters::StatsPresenter
- Inherits:
-
Object
- Object
- AocCli::Presenters::StatsPresenter
- Defined in:
- lib/aoc_cli/presenters/stats_presenter.rb
Defined Under Namespace
Modules: Icons
Instance Attribute Summary collapse
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
-
#initialize(stats) ⇒ StatsPresenter
constructor
A new instance of StatsPresenter.
- #progress_icons(day) ⇒ Object
- #total_progress ⇒ Object
Constructor Details
#initialize(stats) ⇒ StatsPresenter
Returns a new instance of StatsPresenter.
6 7 8 |
# File 'lib/aoc_cli/presenters/stats_presenter.rb', line 6 def initialize(stats) @stats = stats end |
Instance Attribute Details
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
4 5 6 |
# File 'lib/aoc_cli/presenters/stats_presenter.rb', line 4 def stats @stats end |
Instance Method Details
#progress_icons(day) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/aoc_cli/presenters/stats_presenter.rb', line 16 def progress_icons(day) case stats.progress(day) when 0 then Icons::INCOMPLETE when 1 then Icons::HALF_COMPLETE when 2 then Icons::COMPLETE else raise end end |
#total_progress ⇒ Object
10 11 12 13 14 |
# File 'lib/aoc_cli/presenters/stats_presenter.rb', line 10 def total_progress total = 1.upto(25).map { |day| stats.progress(day) }.sum "#{total}/50" end |