Class: AocCli::Database::Calendar::Part
- Inherits:
-
Object
- Object
- AocCli::Database::Calendar::Part
- Defined in:
- lib/aoc_cli/database.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #get ⇒ Object
- #increment ⇒ Object
-
#initialize(u: Metafile.get(:user), y: Metafile.get(:year), d: Metafile.get(:day)) ⇒ Part
constructor
A new instance of Part.
- #where ⇒ Object
Constructor Details
#initialize(u: Metafile.get(:user), y: Metafile.get(:year), d: Metafile.get(:day)) ⇒ Part
Returns a new instance of Part.
202 203 204 205 206 207 208 209 |
# 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 |
Instance Attribute Details
#day ⇒ Object (readonly)
Returns the value of attribute day.
201 202 203 |
# File 'lib/aoc_cli/database.rb', line 201 def day @day end |
#db ⇒ Object (readonly)
Returns the value of attribute db.
201 202 203 |
# File 'lib/aoc_cli/database.rb', line 201 def db @db end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
201 202 203 |
# File 'lib/aoc_cli/database.rb', line 201 def user @user end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
201 202 203 |
# File 'lib/aoc_cli/database.rb', line 201 def year @year end |
Instance Method Details
#get ⇒ Object
210 211 212 213 |
# 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 ⇒ Object
214 215 216 |
# File 'lib/aoc_cli/database.rb', line 214 def increment db.update(t:"calendar", val:{stars:get}, where:where) end |
#where ⇒ Object
217 218 219 220 |
# File 'lib/aoc_cli/database.rb', line 217 def where { year:"'#{year}'", day:"'#{day}'" } end |