Class: Passphrase::WordlistDatabase
- Inherits:
-
Object
- Object
- Passphrase::WordlistDatabase
- Defined in:
- lib/passphrase/wordlist_database.rb
Overview
This class encapsulates the Diceware wordlist database file and dispatches one of two table query objects via the #from method.
Class Method Summary collapse
-
.connect ⇒ Object
A “connect” method seems more natural than “new” when connecting to a database.
Instance Method Summary collapse
- #from(table) ⇒ Language, Word (also: #[])
-
#initialize ⇒ WordlistDatabase
constructor
A new instance of WordlistDatabase.
Constructor Details
#initialize ⇒ WordlistDatabase
Returns a new instance of WordlistDatabase.
80 81 82 83 84 85 |
# File 'lib/passphrase/wordlist_database.rb', line 80 def initialize wordlist_file = "wordlist/words.sqlite3" wordlist_path = File.join(File.dirname(__FILE__), wordlist_file) raise "Wordlist database file not found" unless File.exist?(wordlist_path) @db = SQLite3::Database.new(wordlist_path, readonly: true) end |
Class Method Details
.connect ⇒ Object
A “connect” method seems more natural than “new” when connecting to a database.
76 77 78 |
# File 'lib/passphrase/wordlist_database.rb', line 76 def self.connect new end |