This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqlocktwo.rb
72 lines (61 loc) · 2.57 KB
/
qlocktwo.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env ruby
require 'date'
now = DateTime.now
hour = now.hour
minute = now.min
minutes = [
" \n \n \n ",
" \n FIVE \n \nPAST ",
" \n \n TEN \nPAST ",
"A QUARTER \n \n \nPAST ",
" \nTWENTY \n \nPAST ",
" \nTWENTYFIVE \n \nPAST ",
" \n \nHALF \nPAST ",
" \nTWENTYFIVE \n TO\n ",
" \nTWENTY \n TO\n ",
"A QUARTER \n \n TO \n ",
" \n \n TEN TO\n ",
" \n FIVE \n TO \n "
]
hours = [
" \n \n \n \n TWELVE\n ",
" \nONE \n \n \n \n ",
" \n \n TWO\n \n \n ",
" \n THREE\n \n \n \n ",
" \n \nFOUR \n \n \n ",
" \n \n FIVE \n \n \n ",
" \n SIX \n \n \n \n ",
" \n \n \n \nSEVEN \n ",
" \n \n \nEIGHT \n \n ",
"NINE\n \n \n \n \n ",
" \n \n \n \n \nTEN ",
" \n \n \n ELEVEN\n \n ",
" \n \n \n \n TWELVE\n "
]
output = "IT IS \n"
output+= minutes[minute/5]
hour -=12 if hour > 12 #convert from 24hours format
if(minute >= 35)
if(hour == 12)
hour = 1
else
hour += 1
end
end
output+= hours[hour]
output+="OCLOCK" if minute/5 == 0
if(ARGV.include?("-a") || ARGV.include?("-an") || ARGV.include?("-na"))
antistring ="ITLISASTIME\nACQUARTERDC\nTWENTYFIVEX\nHALFTENOFTO\nPASTERUNINE\nONESIXTHREE\nFOURFIVETWO\nEIGHTELEVEN\nSEVENTWELVE\nTENSEOCLOCK"
(0..output.length-1).each { |i| antistring[i] = (output[i] == ?\s || output[i]==?\n) ? antistring[i]:?\s }
if(ARGV.include?("-n") || ARGV.include?("-an") || ARGV.include?("-na"))
puts antistring
else
antistring.each_byte { | l | print l.chr + (l==?\n ? "" : " ") }
end
elsif(ARGV.include?("-n"))
puts output
elsif(ARGV.length > 0)
printf "Not valid use:\n\n -a to display the 'anti-string'\n -n display the string without spaces\n"
else
output.each_byte { | l | print l.chr + (l==?\n ? "" : " ") }
end