Class: Cliptic::Database::State
- Includes:
- Chars
- Defined in:
- lib/cliptic/database.rb
Direct Known Subclasses
Constant Summary
Constants included from Chars
Chars::Block, Chars::HL, Chars::LL, Chars::LS, Chars::LU, Chars::MS, Chars::Nums, Chars::RL, Chars::RS, Chars::RU, Chars::TD, Chars::TL, Chars::TR, Chars::TU, Chars::Tick, Chars::VL, Chars::XX
Instance Attribute Summary collapse
-
#chars ⇒ Object
readonly
Returns the value of attribute chars.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#done ⇒ Object
readonly
Returns the value of attribute done.
-
#n_done ⇒ Object
readonly
Returns the value of attribute n_done.
-
#n_tot ⇒ Object
readonly
Returns the value of attribute n_tot.
-
#reveals ⇒ Object
Returns the value of attribute reveals.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Attributes inherited from SQL
Instance Method Summary collapse
- #cols ⇒ Object
- #delete ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(date: Date.today) ⇒ State
constructor
A new instance of State.
- #save(game:) ⇒ Object
Methods included from Chars
Methods inherited from SQL
#drop, #insert, #make_table, #select, #update
Constructor Details
Instance Attribute Details
#chars ⇒ Object (readonly)
Returns the value of attribute chars.
92 93 94 |
# File 'lib/cliptic/database.rb', line 92 def chars @chars end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
92 93 94 |
# File 'lib/cliptic/database.rb', line 92 def date @date end |
#done ⇒ Object (readonly)
Returns the value of attribute done.
92 93 94 |
# File 'lib/cliptic/database.rb', line 92 def done @done end |
#n_done ⇒ Object (readonly)
Returns the value of attribute n_done.
92 93 94 |
# File 'lib/cliptic/database.rb', line 92 def n_done @n_done end |
#n_tot ⇒ Object (readonly)
Returns the value of attribute n_tot.
92 93 94 |
# File 'lib/cliptic/database.rb', line 92 def n_tot @n_tot end |
#reveals ⇒ Object
Returns the value of attribute reveals.
92 93 94 |
# File 'lib/cliptic/database.rb', line 92 def reveals @reveals end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
92 93 94 |
# File 'lib/cliptic/database.rb', line 92 def time @time end |
Instance Method Details
#cols ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/cliptic/database.rb', line 100 def cols { date: :DATE, time: :INT, chars: :TEXT, n_done: :INT, n_tot: :INT, reveals: :INT, done: :INT } end |
#delete ⇒ Object
113 114 115 116 117 |
# File 'lib/cliptic/database.rb', line 113 def delete super(where:{date:date.to_s}) @exists = false set end |
#exists? ⇒ Boolean
107 108 109 |
# File 'lib/cliptic/database.rb', line 107 def exists? @exists || query.count > 0 end |
#save(game:) ⇒ Object
110 111 112 |
# File 'lib/cliptic/database.rb', line 110 def save(game:) exists? ? save_existing(game) : save_new(game) end |