Class: Passphrase::Word
- Inherits:
-
Object
- Object
- Passphrase::Word
- Defined in:
- lib/passphrase/wordlist_database.rb
Overview
This class encapsulates the #where query against the “words” table in the “words” SQLite 3 database. The filter parameter must be a hash that specifies a language and sequence of die rolls.
Instance Method Summary collapse
-
#initialize(db) ⇒ Word
constructor
A new instance of Word.
-
#where(filter) ⇒ String
A string of space-separated words from the wordlist.
Constructor Details
#initialize(db) ⇒ Word
Returns a new instance of Word.
58 59 60 |
# File 'lib/passphrase/wordlist_database.rb', line 58 def initialize(db) @db = db end |
Instance Method Details
#where(filter) ⇒ String
Returns a string of space-separated words from the wordlist.
64 65 66 67 68 69 |
# File 'lib/passphrase/wordlist_database.rb', line 64 def where(filter) sql = "SELECT words " + "FROM words " + "WHERE language = :language AND die_rolls = :die_rolls" @db.get_first_value(sql, filter) end |