Module: Babosa::Characters
Overview
This module provides sets of characters needed for various UTF-8 aware string operations.
Instance Attribute Summary collapse
-
#approximations ⇒ Object
readonly
Hash of UTF-8 - ASCII approximations.
-
#strippable ⇒ Object
readonly
Punctuation and control characters to remove from slug strings.
Instance Method Summary collapse
-
#add_approximations(name, hash) ⇒ Object
Adds a hash of approximations.
Instance Attribute Details
#approximations ⇒ Object (readonly)
Hash of UTF-8 - ASCII approximations.
10 11 12 |
# File 'lib/babosa/characters.rb', line 10 def approximations @approximations end |
#strippable ⇒ Object (readonly)
Punctuation and control characters to remove from slug strings.
12 13 14 |
# File 'lib/babosa/characters.rb', line 12 def strippable @strippable end |
Instance Method Details
#add_approximations(name, hash) ⇒ Object
Adds a hash of approximations.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/babosa/characters.rb', line 28 def add_approximations(name, hash) approximations = @approximations ? @approximations.dup : {} approximations[name.to_sym] = hash.inject({}) do |memo, object| key = object[0].unpack("U").shift value = object[1].unpack("C*") memo[key] = value.length == 1 ? value[0] : value memo end.freeze @approximations = approximations.freeze end |