class String
a built-in String
class
Public Instance Methods
from_albhed(hira: false)
click to toggle source
Translate Al Bhed into English
Example:
>> "Re!".from_albhed => "Hi!"
Arguments:
hira: (Boolean)
# File lib/al_bhed.rb, line 46 def from_albhed(hira: false) chars.inject("") do |results, c| results << (latin?(c) ? from_albhed_to_english(c) : from_albhed_to_japanese(c, hira: hira)) end end
to_albhed()
click to toggle source
Translate into Al Bhed
Example:
>> "Hi!".to_albhed => "Re!"
Arguments:
nothing
# File lib/al_bhed.rb, line 32 def to_albhed chars.inject("") do |results, c| results << (latin?(c) ? from_english_to_albhed(c) : from_japanese_to_albhed(c)) end end
Private Instance Methods
from_albhed_to_english(char)
click to toggle source
# File lib/al_bhed.rb, line 68 def from_albhed_to_english(char) if (idx = AlBhed::DOWNCASED_ALBHEDS.index(char)) AlBhed::DOWNCASES[idx] elsif (idx = AlBhed::UPCASED_ALBHEDS.index(char)) AlBhed::UPCASES[idx] else char end end
from_albhed_to_japanese(char, hira: false)
click to toggle source
# File lib/al_bhed.rb, line 88 def from_albhed_to_japanese(char, hira: false) if (idx = AlBhed::KANA_ALBHEDS.index(char)) hira ? AlBhed::HIRA_KANA[idx] : AlBhed::KATA_KANA[idx] elsif (idx = AlBhed::DAKUON_ALBHEDS.index(char)) hira ? AlBhed::HIRA_DAKUON[idx] : AlBhed::KATA_DAKUON[idx] else char end end
from_english_to_albhed(char)
click to toggle source
# File lib/al_bhed.rb, line 58 def from_english_to_albhed(char) if (idx = AlBhed::DOWNCASES.index(char)) AlBhed::DOWNCASED_ALBHEDS[idx] elsif (idx = AlBhed::UPCASES.index(char)) AlBhed::UPCASED_ALBHEDS[idx] else char end end
from_japanese_to_albhed(char)
click to toggle source
# File lib/al_bhed.rb, line 78 def from_japanese_to_albhed(char) if (idx = AlBhed::HIRA_KANA.index(char) || AlBhed::KATA_KANA.index(char)) AlBhed::KANA_ALBHEDS[idx] elsif (idx = AlBhed::HIRA_DAKUON.index(char) || AlBhed::KATA_DAKUON.index(char)) AlBhed::DAKUON_ALBHEDS[idx] else char end end
latin?(char)
click to toggle source
# File lib/al_bhed.rb, line 54 def latin?(char) ("a".."z").include?(char) || ("A".."Z").include?(char) end