Class: AocCli::Presenters::StatsPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/aoc_cli/presenters/stats_presenter.rb

Defined Under Namespace

Modules: Icons

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#statsObject (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_progressObject



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