Class: MigemoStaticDict
- Inherits:
-
MigemoDict
- Object
- MigemoDict
- MigemoStaticDict
- Defined in:
- lib/migemo-dict.rb
Instance Method Summary collapse
-
#initialize(filename) ⇒ MigemoStaticDict
constructor
A new instance of MigemoStaticDict.
- #lookup(pattern) ⇒ Object
Constructor Details
#initialize(filename) ⇒ MigemoStaticDict
Returns a new instance of MigemoStaticDict.
48 49 50 51 |
# File 'lib/migemo-dict.rb', line 48 def initialize (filename) super(filename) @index = File.new(filename + ".idx").read.unpack "N*" end |
Instance Method Details
#lookup(pattern) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/migemo-dict.rb', line 53 def lookup (pattern) range = @index.bsearch_range do |idx| key, values = decompose(get_line(idx)) key.prefix_match(pattern) end if range range.each do |i| key, values = decompose(get_line(@index[i])) yield(MigemoDictItem.new(key, values)) end end end |