Module: SpeakingId
- Defined in:
- lib/speaking_id/speaking_id.rb,
lib/speaking_id/ascii_approximations.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Constant Summary
collapse
- ASCII_APPROXIMATIONS =
{
196 => [65, 101], 214 => [79, 101], 220 => [85, 101], 223 => [115, 115], 228 => [97, 101], 246 => [111, 101], 252 => [117, 101] }.freeze
Class Method Summary
collapse
Class Method Details
.approximate_char(char) ⇒ Object
.included(base) ⇒ Object
2
3
4
|
# File 'lib/speaking_id/speaking_id.rb', line 2
def self.included(base)
base.send :extend, ClassMethods
end
|
.replace_known_special_chars(chars) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/speaking_id/ascii_approximations.rb', line 13
def replace_known_special_chars(chars)
chars = ActiveSupport::Multibyte.proxy_class.new(chars)
chars = chars.normalize(:kc).unpack('U*')
chars = chars.inject([]) do |result, char|
result << approximate_char(char)
end.flatten.pack('U*')
end
|