Class: Lingo::Language::LexicalHash
- Inherits:
-
Object
- Object
- Lingo::Language::LexicalHash
- Defined in:
- lib/lingo/language/lexical_hash.rb
Overview
– Die Klasse LexicalHash ermöglicht den Zugriff auf die Lingodatenbanken. Im Gegensatz zur Klasse Database, welche nur Strings als Ergebnis zurück gibt, wird hier als Ergebnis ein Array von Lexical-Objekten zurück gegeben. ++
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #close ⇒ Object
-
#initialize(id, lingo) ⇒ LexicalHash
constructor
A new instance of LexicalHash.
Constructor Details
#initialize(id, lingo) ⇒ LexicalHash
Returns a new instance of LexicalHash.
45 46 47 |
# File 'lib/lingo/language/lexical_hash.rb', line 45 def initialize(id, lingo) @src = Database.open(id, lingo) end |
Class Method Details
.open(*args) ⇒ Object
39 40 41 42 43 |
# File 'lib/lingo/language/lexical_hash.rb', line 39 def self.open(*args) yield lexical_hash = new(*args) ensure lexical_hash.close if lexical_hash end |
Instance Method Details
#[](key) ⇒ Object
53 54 55 |
# File 'lib/lingo/language/lexical_hash.rb', line 53 def [](key) Database::Source.lexicals(@src[Unicode.downcase(key)]) end |
#close ⇒ Object
49 50 51 |
# File 'lib/lingo/language/lexical_hash.rb', line 49 def close @src.close end |