class AocCli::Database::Calendar::Part

Attributes

day[R]
db[R]
user[R]
year[R]

Public Class Methods

new(u:Metafile.get(:user), y:Metafile.get(:year), d:Metafile.get(:day)) click to toggle source
# File lib/aoc_cli/database.rb, line 202
def initialize(u:Metafile.get(:user),
                           y:Metafile.get(:year),
                           d:Metafile.get(:day))
        @user = Validate.user(u)
        @year = Validate.year(y)
        @day  = Validate.day(d)
        @db   = Query.new(path:Paths::Database.cfg(user))
end

Public Instance Methods

get() click to toggle source
# File lib/aoc_cli/database.rb, line 210
def get
        db.select(t:"calendar", cols:"stars", where:where)
                .flatten.first.to_i + 1
end
increment() click to toggle source
# File lib/aoc_cli/database.rb, line 214
def increment
        db.update(t:"calendar", val:{stars:get}, where:where)
end
where() click to toggle source
# File lib/aoc_cli/database.rb, line 217
def where
        { year:"'#{year}'",
           day:"'#{day}'" }
end