1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Strive to give better examples.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2002-12-19 20:26:16 +00:00
parent c3cd615aa4
commit d46e835344
3 changed files with 20 additions and 18 deletions

View file

@ -79,13 +79,13 @@ else
if $OPT_birthday
bd = Date.new(*parsedate($OPT_birthday))
else
printf(STDERR, "Birthday (YYYYMMDD) : ")
if (si = STDIN.gets.chop) != ""
STDERR.print("Birthday (YYYYMMDD) : ")
unless (si = STDIN.gets.chop).empty?
bd = Date.new(*parsedate(si))
end
end
if !bd
printf STDERR, "BAD Input Birthday!!\n"
STDERR.print "BAD Input Birthday!!\n"
exit()
end
@ -94,25 +94,23 @@ else
elsif $OPT_date
dd = Date.new(*parsedate($OPT_date))
else
printf(STDERR, "Date [<RETURN> for Systemdate] (YYYYMMDD) : ")
if (si = STDIN.gets.chop) != ""
STDERR.print("Date [<RETURN> for Systemdate] (YYYYMMDD) : ")
unless (si = STDIN.gets.chop).empty?
dd = Date.new(*parsedate(si))
end
end
if !dd
dd = Date.today
end
dd ||= Date.today
if $OPT_v
ausgabeart = "v"
elsif $OPT_g
ausgabeart = "g"
else
printf(STDERR, "Values for today or Graph (v/g) [default g] : ")
STDERR.print("Values for today or Graph (v/g) [default g] : ")
ausgabeart = STDIN.gets.chop
end
end
if (ausgabeart == "v")
if ausgabeart == "v"
printHeader(bd.year, bd.month, bd.day, dd - bd, name_of_week(bd))
print "\n"
@ -128,9 +126,9 @@ else
elsif $OPT_D
display_period = 9
else
printf(STDERR, "Graph for how many days [default 10] : ")
STDERR.printf("Graph for how many days [default 10] : ")
display_period = STDIN.gets.chop
if (display_period == "")
if display_period.empty?
display_period = 9
else
display_period = display_period.to_i - 1

View file

@ -3,15 +3,19 @@
require "socket"
host=(if ARGV.length == 2; ARGV.shift; else "localhost"; end)
if ARGV.length >= 2
host = ARGV.shift
else
host = "localhost"
end
print("Trying ", host, " ...")
STDOUT.flush
s = TCPSocket.open(host, ARGV.shift)
print(" done\n")
print("addr: ", s.addr.join(":"), "\n")
print("peer: ", s.peeraddr.join(":"), "\n")
while gets()
s.write($_)
while line = gets()
s.write(line)
print(s.readline)
end
s.close

View file

@ -9,7 +9,7 @@ addr.shift
printf("server is on %s\n", addr.join(":"))
socks = [gs]
while TRUE
loop do
nsock = select(socks);
next if nsock == nil
for s in nsock[0]
@ -23,7 +23,7 @@ while TRUE
s.close
socks.delete(s)
else
if str = s.gets;
if str = s.gets
s.write(str)
end
end