Class: AocCli::Core::StatsParser
- Inherits:
-
Object
- Object
- AocCli::Core::StatsParser
- Defined in:
- lib/aoc_cli/core/stats_parser.rb
Overview
Calculates a User’s year progress by parsing the CSS classes that are applied to each calendar link in the calendar view.
Constant Summary collapse
- DAY_CLASS_PREFIX =
"calendar-day".freeze
- ONE_STAR_CLASS =
"calendar-complete".freeze
- TWO_STARS_CLASS =
"calendar-verycomplete".freeze
Instance Attribute Summary collapse
-
#calendar_html ⇒ Object
readonly
Returns the value of attribute calendar_html.
Instance Method Summary collapse
-
#initialize(calendar_html) ⇒ StatsParser
constructor
A new instance of StatsParser.
- #to_h ⇒ Object
Constructor Details
#initialize(calendar_html) ⇒ StatsParser
Returns a new instance of StatsParser.
12 13 14 |
# File 'lib/aoc_cli/core/stats_parser.rb', line 12 def initialize(calendar_html) @calendar_html = calendar_html end |
Instance Attribute Details
#calendar_html ⇒ Object (readonly)
Returns the value of attribute calendar_html.
10 11 12 |
# File 'lib/aoc_cli/core/stats_parser.rb', line 10 def calendar_html @calendar_html end |
Instance Method Details
#to_h ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/aoc_cli/core/stats_parser.rb', line 16 def to_h calendar_link_classes.to_h do |classes| day = classes[0].delete_prefix(DAY_CLASS_PREFIX) n_stars = count_stars(classes) [:"day_#{day}", n_stars] end end |