class AocCli::Year::Requests::Stats
Public Instance Methods
page()
click to toggle source
# File lib/aoc_cli/year.rb, line 75 def page :Stats end
parse(raw:)
click to toggle source
# File lib/aoc_cli/year.rb, line 78 def parse(raw:) /You haven't collected/.match?(raw.to_s) ? raw : raw.drop(raw.index{|l| l =~ /^.*Part 1/}) end
stars()
click to toggle source
# File lib/aoc_cli/year.rb, line 82 def stars data.map{|l| l.scan(/^\s+\d+/)&.first} .reject{|s| s == nil} .map{|s| [s.to_i, data .grep(/^.*#{s}.*(\-.*){3}$/) .count == 0 ? 2 : 1]}.to_h end
total_stars()
click to toggle source
# File lib/aoc_cli/year.rb, line 89 def total_stars stars.values.reduce(:+).to_i || 0 end