Created
August 27, 2011 22:51
-
-
Save TravelingTechGuy/1175969 to your computer and use it in GitHub Desktop.
Create a fuzzy, verbal clock
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
#!/usr/bin/env ruby | |
hour, minute = Time.now.strftime('%I').to_i, Time.now.min | |
ones = %w{ nil one two three four five six seven eight nine } | |
teens = %w{ ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen } | |
tens = %w{ nil nil twenty thirty forty fifty } | |
minute_str = case minute | |
when 0 then 'o-clock' | |
when 1..9 then "o-#{ones[minute]}" | |
when 10..19 then teens[minute - 10] | |
else tens[minute.to_s[0,1].to_i] + (minute.to_s[1,1].to_i == 0 ? '' : "-#{ones[minute.to_s[1,1].to_i]}") | |
end | |
print "#{[ones,teens].flatten[hour]} #{minute_str}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment