Class: Cliptic::Database::Scores
- Inherits:
-
SQL
- Object
- SQL
- Cliptic::Database::Scores
show all
- Defined in:
- lib/cliptic/database.rb
Instance Attribute Summary
Attributes inherited from SQL
#db, #table
Instance Method Summary
collapse
Methods inherited from SQL
#delete, #drop, #insert, #make_table, #select, #update
Constructor Details
#initialize ⇒ Scores
Returns a new instance of Scores.
219
220
221
|
# File 'lib/cliptic/database.rb', line 219
def initialize
super(table:"scores").make_table
end
|
Instance Method Details
#add(game:) ⇒ Object
230
231
232
|
# File 'lib/cliptic/database.rb', line 230
def add(game:)
insert(values:build(game:game))
end
|
#build(game:) ⇒ Object
237
238
239
240
241
242
243
244
|
# File 'lib/cliptic/database.rb', line 237
def build(game:)
{
date:game.date.to_s,
date_done:Date.today.to_s,
time:game.timer.time.strftime("%T"),
reveals:game.state.reveals
}
end
|
#cols ⇒ Object
222
223
224
225
226
227
228
229
|
# File 'lib/cliptic/database.rb', line 222
def cols
{
date: :DATE,
date_done: :DATE,
time: :TEXT,
reveals: :INT
}
end
|
#select_list ⇒ Object
233
234
235
236
|
# File 'lib/cliptic/database.rb', line 233
def select_list
select(cols:"*", where:{reveals:0},
order:{time:"ASC"}, limit:10)
end
|