Class: AocCli::Database::Stats::Init
- Inherits:
-
Object
- Object
- AocCli::Database::Stats::Init
- Defined in:
- lib/aoc_cli/database.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#now ⇒ Object
readonly
Returns the value of attribute now.
-
#part ⇒ Object
readonly
Returns the value of attribute part.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #cols ⇒ Object
- #data ⇒ Object
- #init ⇒ Object
-
#initialize(u: Metafile.get(:user), y: Metafile.get(:year), d: Metafile.get(:day), p: Metafile.get(:part)) ⇒ Init
constructor
A new instance of Init.
Constructor Details
#initialize(u: Metafile.get(:user), y: Metafile.get(:year), d: Metafile.get(:day), p: Metafile.get(:part)) ⇒ Init
Returns a new instance of Init.
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/aoc_cli/database.rb', line 91 def initialize(u:Metafile.get(:user), y:Metafile.get(:year), d:Metafile.get(:day), p:Metafile.get(:part)) @user = Validate.user(u) @year = Validate.year(y) @day = Validate.day(d) @part = p @now = Time.now @db = Query.new(path:Paths::Database.cfg(user)) .table(t:"stats", cols:cols) end |
Instance Attribute Details
#day ⇒ Object (readonly)
Returns the value of attribute day.
90 91 92 |
# File 'lib/aoc_cli/database.rb', line 90 def day @day end |
#db ⇒ Object (readonly)
Returns the value of attribute db.
90 91 92 |
# File 'lib/aoc_cli/database.rb', line 90 def db @db end |
#now ⇒ Object (readonly)
Returns the value of attribute now.
90 91 92 |
# File 'lib/aoc_cli/database.rb', line 90 def now @now end |
#part ⇒ Object (readonly)
Returns the value of attribute part.
90 91 92 |
# File 'lib/aoc_cli/database.rb', line 90 def part @part end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
90 91 92 |
# File 'lib/aoc_cli/database.rb', line 90 def user @user end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
90 91 92 |
# File 'lib/aoc_cli/database.rb', line 90 def year @year end |
Instance Method Details
#cols ⇒ Object
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/aoc_cli/database.rb', line 103 def cols { year: :INT, day: :INT, part: :INT, dl_time: :TEXT, end_time: :TEXT, elapsed: :TEXT, attempts: :INT, correct: :INT } end |
#data ⇒ Object
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/aoc_cli/database.rb', line 116 def data [ "'#{year}'", "'#{day}'", "'#{part}'", "'#{now}'", "NULL", "NULL", "'0'", "'0'" ] end |
#init ⇒ Object
113 114 115 |
# File 'lib/aoc_cli/database.rb', line 113 def init db.insert(t:"stats", val:data) end |