6 # by Yasuo OHBA(STAFS Development Room)
15 # Newsgroups: comp.sources.misc,de.comp.sources.os9
16 # From: fkk@stasys.sta.sub.org (Frank Kaefer)
17 # Subject: v41i126: br - Biorhythm v3.0, Part01/01
18 # Message-ID: <1994Feb1.070616.15982@sparky.sterling.com>
19 # Sender: kent@sparky.sterling.com (Kent Landfield)
20 # Organization: Sterling Software
21 # Date: Tue, 1 Feb 1994 07:06:16 GMT
23 # Posting-number: Volume 41, Issue 126
24 # Archive-name: br/part01
25 # Environment: basic, dos, os9
30 require "optparse/date"
32 def printHeader(y, m, d, p, w)
33 print "\n>>> Biorhythm <<<\n"
34 printf "The birthday %04d.%02d.%02d is a %s\n", y, m, d, w
35 printf "Age in days: [%d]\n\n", p
41 phys = (50.0 * (1.0 + sin((z / 23.0 - (z / 23)) * 360.0 * pi / 180.0))).to_i
42 emot = (50.0 * (1.0 + sin((z / 28.0 - (z / 28)) * 360.0 * pi / 180.0))).to_i
43 geist =(50.0 * (1.0 + sin((z / 33.0 - (z / 33)) * 360.0 * pi / 180.0))).to_i
44 return phys, emot, geist
60 ARGV.options do |opts|
61 opts.on("-b", "--birthday=DATE", Date, "specify your birthday"){|v|
62 options[:birthday] = v
64 opts.on("--date=DATE", Date, "specify date to show"){|v|
67 opts.on("-g", "--show-graph", TrueClass, "show graph (default)"){|v|
70 opts.on("-v", "--show-values", TrueClass, "show values"){|v|
73 opts.on("--days=DAYS", Integer, "graph range (only in effect for graph)"){|v|
74 options[:days] = v - 1
76 opts.on_tail("-h", "--help", "show this message"){puts opts; exit}
80 puts "Error: #{ex.message}"
86 bd = options[:birthday] || Date.parse(prompt("Your birthday (YYYYMMDD): "))
87 dd = options[:date] || Date.today
88 ausgabeart = options[:graph] ? "g" : "v"
89 display_period = options[:days]
92 printHeader(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a"))
95 phys, emot, geist = getPosition(dd - bd)
96 printf "Biorhythm: %04d.%02d.%02d\n", dd.year, dd.month, dd.day
97 printf "Physical: %d%%\n", phys
98 printf "Emotional: %d%%\n", emot
99 printf "Mental: %d%%\n", geist
102 printHeader(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a"))
103 print " P=physical, E=emotional, M=mental\n"
104 print " -------------------------+-------------------------\n"
105 print " Bad Condition | Good Condition\n"
106 print " -------------------------+-------------------------\n"
108 (dd - bd).step(dd - bd + display_period) do |z|
109 phys, emot, geist = getPosition(z)
111 printf "%04d.%02d.%02d : ", dd.year, dd.month, dd.day
112 p = (phys / 2.0 + 0.5).to_i
113 e = (emot / 2.0 + 0.5).to_i
114 g = (geist / 2.0 + 0.5).to_i
123 print " -------------------------+-------------------------\n\n"