class AocCli::Database::Stats::Complete
Attributes
n_attempts[R]
Public Class Methods
new(u:Metafile.get(:user), y:Metafile.get(:year), d:Metafile.get(:day), p:Metafile.get(:part), n:)
click to toggle source
Calls superclass method
AocCli::Database::Stats::Init::new
# File lib/aoc_cli/database.rb, line 129 def initialize(u:Metafile.get(:user), y:Metafile.get(:year), d:Metafile.get(:day), p:Metafile.get(:part), n:) super(u:u, y:y, d:d, p:p) @n_attempts = n end
Public Instance Methods
dl_time()
click to toggle source
# File lib/aoc_cli/database.rb, line 158 def dl_time @dl_time ||= Time.parse(db .select(t:"stats", cols:"dl_time", where:where) .flatten.first) end
elapsed()
click to toggle source
# File lib/aoc_cli/database.rb, line 151 def elapsed @elapsed ||= hms(now - dl_time) end
hms(seconds)
click to toggle source
# File lib/aoc_cli/database.rb, line 154 def hms(seconds) [seconds/3600, seconds/60 % 60, seconds % 60] .map{|t| t.to_i.to_s.rjust(2, "0")}.join(":") end
update()
click to toggle source
# File lib/aoc_cli/database.rb, line 137 def update db.update(t:"stats", val:val, where:where) end
val()
click to toggle source
# File lib/aoc_cli/database.rb, line 140 def val { elapsed: "'#{elapsed}'", end_time: "'#{now}'", attempts: "'#{n_attempts}'", correct: "'1'" } end
where()
click to toggle source
# File lib/aoc_cli/database.rb, line 146 def where { year: year, day: day, part: part } end