Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/ka/string.rb
Constant Summary collapse
- GEO =
Translation between legacy character sets.
'ÀÁÂÃÄÅÆÈÉÊËÌÍÏÐÑÒÓÔÖרÙÚÛÜÝÞßàáãä'- KA =
'აბგდევზთიკლმნოპჟრსტუფქღყშჩცძწჭხჯჰ'- LAT =
'abgdevzTiklmnopJrstufqRySCcZwWxjh'
Instance Method Summary collapse
-
#to_geo ⇒ Object
Translates georgian into GEO encoding.
-
#to_ka(type = 'geo') ⇒ Object
Translates this string into true georgian unicode symbols.
-
#to_lat ⇒ Object
Translates georgian into LAT encoding.
- #translate(from, to) ⇒ Object
Instance Method Details
#to_geo ⇒ Object
Translates georgian into GEO encoding.
44 45 46 |
# File 'lib/ka/string.rb', line 44 def to_geo self.translate(KA, GEO) end |
#to_ka(type = 'geo') ⇒ Object
Translates this string into true georgian unicode symbols. Use type paramter to specify which type of conversion to use. Possible values for this parameters are geo (default), lat and all.
35 36 37 38 39 40 41 |
# File 'lib/ka/string.rb', line 35 def to_ka(type = 'geo') case type.to_s when 'all' then self.translate("#{GEO}#{LAT}", "#{KA}#{KA}") when 'lat' then self.translate(LAT, KA) else self.translate(GEO, KA) end end |
#to_lat ⇒ Object
Translates georgian into LAT encoding.
49 50 51 |
# File 'lib/ka/string.rb', line 49 def to_lat self.translate("#{GEO}#{KA}", "#{LAT}#{LAT}") end |
#translate(from, to) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/ka/string.rb', line 23 def translate(from, to) txt = "" self.split('').each do |c| indx = from.index(c) txt << (indx ? to[indx] : c) end txt end |