Skip to content

Instantly share code, notes, and snippets.

@kitallis
Forked from anonymous/file.rb
Created October 6, 2011 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitallis/1267247 to your computer and use it in GitHub Desktop.
Save kitallis/1267247 to your computer and use it in GitHub Desktop.
File.open("words.txt") { |f|
f.each { |word|
word = word.to_s.chomp.downcase
p word
word.each_char { |l| # extracting letters
puts "\t Current letter: #{l}"
num = case l
when 'a'..'c' then 2
when 'd'..'f' then 3
when 'g'..'i' then 4
when 'j'..'l' then 5
when 'm'..'o' then 6
when 'p'..'s' then 7
when 't', 'u', 'v' then 8
else 9
end
puts num
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment