~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to sample/biorhythm.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/local/bin/ruby
2
2
#
3
 
#               biorhythm.rb - 
 
3
#               biorhythm.rb -
4
4
#                       $Release Version: $
5
 
#                       $Revision: 25189 $
 
5
#                       $Revision: 31573 $
6
6
#                       by Yasuo OHBA(STAFS Development Room)
7
7
#
8
8
# --
9
9
#
10
 
#       
 
10
#
11
11
#
12
12
 
13
13
# probably based on:
29
29
require "optparse"
30
30
require "optparse/date"
31
31
 
32
 
def printHeader(y, m, d, p, w)
 
32
def print_header(y, m, d, p, w)
33
33
  print "\n>>> Biorhythm <<<\n"
34
34
  printf "The birthday %04d.%02d.%02d is a %s\n", y, m, d, w
35
35
  printf "Age in days: [%d]\n\n", p
36
36
end
37
37
 
38
 
def getPosition(z)
 
38
def get_position(z)
39
39
  pi = Math::PI
40
40
  z = Integer(z)
41
41
  phys = (50.0 * (1.0 + sin((z / 23.0 - (z / 23)) * 360.0 * pi / 180.0))).to_i
89
89
display_period = options[:days]
90
90
 
91
91
if ausgabeart == "v"
92
 
  printHeader(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a"))
 
92
  print_header(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a"))
93
93
  print "\n"
94
 
  
95
 
  phys, emot, geist = getPosition(dd - bd)
 
94
 
 
95
  phys, emot, geist = get_position(dd - bd)
96
96
  printf "Biorhythm:   %04d.%02d.%02d\n", dd.year, dd.month, dd.day
97
97
  printf "Physical:    %d%%\n", phys
98
98
  printf "Emotional:   %d%%\n", emot
99
99
  printf "Mental:      %d%%\n", geist
100
100
  print "\n"
101
101
else
102
 
  printHeader(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a"))
 
102
  print_header(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a"))
103
103
  print "                     P=physical, E=emotional, M=mental\n"
104
104
  print "             -------------------------+-------------------------\n"
105
105
  print "                     Bad Condition    |    Good Condition\n"
106
106
  print "             -------------------------+-------------------------\n"
107
 
  
 
107
 
108
108
  (dd - bd).step(dd - bd + display_period) do |z|
109
 
    phys, emot, geist = getPosition(z)
110
 
    
 
109
    phys, emot, geist = get_position(z)
 
110
 
111
111
    printf "%04d.%02d.%02d : ", dd.year, dd.month, dd.day
112
112
    p = (phys / 2.0 + 0.5).to_i
113
113
    e = (emot / 2.0 + 0.5).to_i