Last active
December 5, 2015 20:12
-
-
Save msroot/5674c1fe05b787782f58 to your computer and use it in GitHub Desktop.
Greek.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Greek | |
| APPROXIMATIONS = { | |
| "A" => "Α", | |
| "a" => "α", | |
| "V" => "Β", | |
| "v" => "β", | |
| "G" => "Γ", | |
| "g" => "γ", | |
| "D" => "Δ", | |
| "d" => "δ", | |
| "E" => "Ε", | |
| "e" => "ε", | |
| "Z" => "Ζ", | |
| "z" => "ζ", | |
| "I" => "Η", | |
| "i" => "η", | |
| "TH" => "Θ", | |
| "th" => "θ", | |
| "I" => "Ι", | |
| "i" => "ι", | |
| "K" => "Κ", | |
| "k" => "κ", | |
| "L" => "Λ", | |
| "l" => "λ", | |
| "M" => "Μ", | |
| "m" => "μ", | |
| "N" => "Ν", | |
| "n" => "ν", | |
| "KS" => "Ξ", | |
| "ks" => "ξ", | |
| "O" => "Ο", | |
| "o" => "ο", | |
| "P" => "Π", | |
| "p" => "π", | |
| "R" => "Ρ", | |
| "r" => "ρ", | |
| "S" => "Σ", | |
| "s" => "σ", | |
| "s" => "ς", | |
| "T" => "Τ", | |
| "t" => "τ", | |
| "Y" => "Υ", | |
| "y" => "υ", | |
| "F" => "Φ", | |
| "f" => "φ", | |
| "X" => "Χ", | |
| "x" => "χ", | |
| "PS" => "Ψ", | |
| "ps" => "ψ", | |
| "O" => "Ω", | |
| "o" => "ω" | |
| } | |
| def self.translate(word) | |
| new_word = "" | |
| word.each_char {|c| new_word << APPROXIMATIONS[c] rescue ""} | |
| new_word | |
| end | |
| end | |
| # Greek.translate("Hello") | |
| # 2.1.3 :063 > Greek.translate("Hello") | |
| # "ελλω" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment