Class: Kotoshu::Readers::Ignore
- Inherits:
-
Object
- Object
- Kotoshu::Readers::Ignore
- Defined in:
- lib/kotoshu/readers/aff_data.rb
Overview
Ignore characters for lookup/suggest.
Instance Attribute Summary collapse
-
#chars ⇒ String
Characters to ignore.
-
#translation_table ⇒ Hash
Translation table for removal.
Instance Method Summary collapse
-
#initialize(chars) ⇒ Ignore
constructor
Create a new ignore set.
-
#remove(str) ⇒ String
Remove ignored characters from string.
Constructor Details
#initialize(chars) ⇒ Ignore
Create a new ignore set.
110 111 112 113 114 |
# File 'lib/kotoshu/readers/aff_data.rb', line 110 def initialize(chars) @chars = chars # Create translation table that removes these characters @translation_table = chars.each_char.each_with_index.to_h end |
Instance Attribute Details
#chars ⇒ String
Characters to ignore
104 105 106 |
# File 'lib/kotoshu/readers/aff_data.rb', line 104 def chars @chars end |
#translation_table ⇒ Hash
Translation table for removal
104 105 106 |
# File 'lib/kotoshu/readers/aff_data.rb', line 104 def translation_table @translation_table end |
Instance Method Details
#remove(str) ⇒ String
Remove ignored characters from string.
120 121 122 |
# File 'lib/kotoshu/readers/aff_data.rb', line 120 def remove(str) str.chars.reject { |c| @translation_table.key?(c) }.join end |