Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/is_taggable/string.rb
Overview
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.unpack(string) ⇒ Object
4 5 6 7 |
# File 'lib/is_taggable/string.rb', line 4 def unpack(string) return ActiveSupport::Multibyte::Chars.g_unpack(string).collect{ |c| c[0] } if ActiveSupport::Multibyte::Chars.respond_to?(:g_unpack) string.split('').collect{ |c| c.chars[0] } end |
Instance Method Details
#to_ascii ⇒ Object
10 11 12 13 14 |
# File 'lib/is_taggable/string.rb', line 10 def to_ascii # split in muti-byte aware fashion and translate characters over 127 # and dropping characters not in the translation hash String.unpack(self).collect{ |c| (c <= 127) ? c.chr : translation_hash[c] }.join end |