summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/biorhythm.rb10
-rw-r--r--sample/list.rb16
-rw-r--r--sample/mine.rb36
-rw-r--r--sample/rbc.rb8
-rw-r--r--sample/rcs.rb10
5 files changed, 40 insertions, 40 deletions
diff --git a/sample/biorhythm.rb b/sample/biorhythm.rb
index 50ad1f2ef7..d2cbb113ec 100644
--- a/sample/biorhythm.rb
+++ b/sample/biorhythm.rb
@@ -19,11 +19,11 @@ def usage()
print "Usage:\n"
print "biorhythm.rb [options]\n"
print " options...\n"
- print " -D YYYYMMDD(birthday) : すべて default 値を使う. \n"
- print " --sdate | --date YYYYMMDD : system date もしくは指定した日付を使う.\n"
- print " --birthday YYYYMMDD : 誕生日の指定をする. \n"
- print " -v | -g : Values or Graph の指定. \n"
- print " --days DAYS : 期間の指定をする(Graph の時のみ有効). \n"
+ print " -D YYYYMMDD(birthday) : use default values.\n"
+ print " --sdate | --date YYYYMMDD : use system date; use specified date.\n"
+ print " --birthday YYYYMMDD : specifies your birthday.\n"
+ print " -v | -g : show values or graph.\n"
+ print " --days DAYS : graph range (only in effect for graphs).\n"
print " --help : help\n"
end
$USAGE = 'usage'
diff --git a/sample/list.rb b/sample/list.rb
index 76035e67d6..17eefae85a 100644
--- a/sample/list.rb
+++ b/sample/list.rb
@@ -1,8 +1,8 @@
# Linked list example
class MyElem
- # オブジェクト生成時に自動的に呼ばれるメソッド
+ # object initializer called from Class#new
def initialize(item)
- # @変数はインスタンス変数(宣言は要らない)
+ # @variables are instance variable, no declaration needed
@data = item
@succ = nil
end
@@ -15,7 +15,7 @@ class MyElem
@succ
end
- # 「obj.data = val」としたときに暗黙に呼ばれるメソッド
+ # the method invoked by ``obj.data = val''
def succ=(new)
@succ = new
end
@@ -40,12 +40,12 @@ class MyList
end
end
- # オブジェクトを文字列に変換するメソッド
- # これを再定義するとprintでの表現が変わる
+ # the method to convert object into string.
+ # redefining this will affect print.
def to_s
str = "<MyList:\n";
for elt in self
- # 「str = str + elt.data.to_s + "\n"」の省略形
+ # short form of ``str = str + elt.data.to_s + "\n"''
str += elt.data.to_s + "\n"
end
str += ">"
@@ -64,7 +64,7 @@ class Point
end
end
-# 大域変数は`$'で始まる.
+# global variables are start with `$'.
$list1 = MyList.new
$list1.add_to_list(10)
$list1.add_to_list(20)
@@ -75,6 +75,6 @@ $list2.add_to_list(20)
$list2.add_to_list(Point.new(4, 5))
$list2.add_to_list($list1)
-# 曖昧でない限りメソッド呼び出しの括弧は省略できる
+# parenthesises around method arguments can be ommitted unless ambiguous.
print "list1:\n", $list1, "\n"
print "list2:\n", $list2, "\n"
diff --git a/sample/mine.rb b/sample/mine.rb
index b9557d54a2..96af32e7e4 100644
--- a/sample/mine.rb
+++ b/sample/mine.rb
@@ -10,19 +10,19 @@ class Board
end
def put(x, y, col, str)
pos(x,y); colorstr(43,str)
- pos(0,@hi); print "$B;D$j(B:",@mc,"/",@total," "
+ pos(0,@hi); print "残り:",@mc,"/",@total," "
pos(x,y)
end
private :clr, :pos, :colorstr, :put
- CHR=["$B!&(B","$B#1(B","$B#2(B","$B#3(B","$B#4(B","$B#5(B","$B#6(B","$B#7(B","$B#8(B","$B!z(B","$B!|(B","@@"]
+ CHR=["・","1","2","3","4","5","6","7","8","★","●","@@"]
COL=[46,43,45] # default,opened,over
def initialize(h,w,m)
- # $B%2!<%`HW$N@8@.(B(h:$B=D!$(Bw:$B2#!$(Bm:$BGzCF$N?t(B)
+ # ゲーム盤の生成(h:縦,w:横,m:爆弾の数)
@hi=h; @wi=w; @m=m
reset
end
def reset
- # $B%2!<%`HW$r(B($B:F(B)$B=i4|2=$9$k(B
+ # ゲーム盤を(再)初期化する
srand()
@cx=0; @cy=0; @mc=@m
@over=false
@@ -44,7 +44,7 @@ class Board
pos(@cx,@cy)
end
def mark
- # $B8=:_$N%+!<%=%k0LCV$K%^!<%/$r$D$1$k(B
+ # 現在のカーソル位置にマークをつける
if @state[@wi*@cy+@cx] != nil then return end
@state[@wi*@cy+@cx] = "MARK"
@mc=@mc-1;
@@ -52,8 +52,8 @@ class Board
put(@cx, @cy, COL[1], CHR[9])
end
def open(x=@cx,y=@cy)
- # $B8=:_$N%+!<%=%k0LCV$r%*!<%W%s$K$9$k(B
- # $BGzCF$,$"$l$P%2!<%`%*!<%P!<(B
+ # 現在のカーソル位置をオープンにする
+ # 爆弾があればゲームオーバー
if @state[@wi*y+x] =="OPEN" then return 0 end
if @state[@wi*y+x] == nil then @total=@total-1 end
if @state[@wi*y+x] =="MARK" then @mc=@mc+1 end
@@ -73,7 +73,7 @@ class Board
pos(@cx,@cy)
end
def fetch(x,y)
- # (x,y)$B$N0LCV$NGzCF$N?t(B(0 or 1)$B$rJV$9(B
+ # (x,y)の位置の爆弾の数(0 or 1)を返す
if x < 0 then 0
elsif x >= @wi then 0
elsif y < 0 then 0
@@ -83,13 +83,13 @@ class Board
end
end
def count(x,y)
- # (x,y)$B$KNY@\$9$kGzCF$N?t$rJV$9(B
+ # (x,y)に隣接する爆弾の数を返す
fetch(x-1,y-1)+fetch(x,y-1)+fetch(x+1,y-1)+
fetch(x-1,y) + fetch(x+1,y)+
fetch(x-1,y+1)+fetch(x,y+1)+fetch(x+1,y+1)
end
def over(win)
- # $B%2!<%`$N=*N;(B
+ # ゲームの終了
quit
unless win
pos(@cx,@cy); print CHR[11]
@@ -100,8 +100,8 @@ class Board
end
end
def over?
- # $B%2!<%`$N=*N;%A%'%C%/(B
- # $B=*N;=hM}$b8F$S=P$9(B
+ # ゲームの終了チェック
+ # 終了処理も呼び出す
remain = (@mc+@total == 0)
if @over || remain
over(remain)
@@ -111,8 +111,8 @@ class Board
end
end
def quit
- # $B%2!<%`$NCfCG(B($B$^$?$O=*N;(B)
- # $BHWLL$rA4$F8+$;$k(B
+ # ゲームの中断(または終了)
+ # 盤面を全て見せる
@hi.times do|y|
pos(0,y)
@wi.times do|x|
@@ -122,19 +122,19 @@ class Board
end
end
def down
- # $B%+!<%=%k$r2<$K(B
+ # カーソルを下に
if @cy < @hi-1 then @cy=@cy+1; pos(@cx, @cy) end
end
def up
- # $B%+!<%=%k$r>e$K(B
+ # カーソルを上に
if @cy > 0 then @cy=@cy-1; pos(@cx, @cy) end
end
def left
- # $B%+!<%=%k$r:8$K(B
+ # カーソルを左に
if @cx > 0 then @cx=@cx-1; pos(@cx, @cy) end
end
def right
- # $B%+!<%=%k$r1&$K(B
+ # カーソルを右に
if @cx < @wi-1 then @cx=@cx+1; pos(@cx, @cy) end
end
end
diff --git a/sample/rbc.rb b/sample/rbc.rb
index 83796255cc..9f1ab9443d 100644
--- a/sample/rbc.rb
+++ b/sample/rbc.rb
@@ -273,7 +273,7 @@ module BC_APPLICATION__
rests.unshift op
identify_number(rests)
else
- # obj.if などの対応
+ # handle ``obj.if'' and such
identify_identifier(rests, TRUE)
@lex_state = EXPR_ARG
end
@@ -344,7 +344,7 @@ module BC_APPLICATION__
@lex_state = EXPR_BEG
end
end
- @OP.def_rule('$') do
+ @OP.def_rule('$') do #'
|op, rests|
identify_gvar(rests)
end
@@ -466,7 +466,7 @@ module BC_APPLICATION__
print token, "\n" if CONFIG[:DEBUG]
if state = CLAUSE_STATE_TRANS[token]
if @lex_state != EXPR_BEG and token =~ /^(if|unless|while|until)/
- # 修飾子
+ # modifiers
else
if ENINDENT_CLAUSE.include?(token)
@indent += 1
@@ -640,7 +640,7 @@ module BC_APPLICATION__
def_exception :ErrNodeAlreadyExists, "node already exists"
class Node
- # postprocがなければ抽象ノード, nilじゃなければ具象ノード
+ # abstract node if postproc is nil.
def initialize(preproc = nil, postproc = nil)
@Tree = {}
@preproc = preproc
diff --git a/sample/rcs.rb b/sample/rcs.rb
index 3f74da9ef2..7c091936f3 100644
--- a/sample/rcs.rb
+++ b/sample/rcs.rb
@@ -1,12 +1,12 @@
# random dot steraogram
# usage: rcs.rb rcs.dat
-sw = 40.0 # p^[
-dw = 78.0 # Random Character Streogram
+sw = 40.0 # width of original pattern
+dw = 78.0 # width of generating Random Character Streogram
hdw = dw / 2.0
-w = 20.0 #
-h =1.0 #
-d = 0.2 # P
+w = 20.0 # distance between eyes
+h =1.0 # distance from screen and base plane
+d = 0.2 # z value unit
ss="abcdefghijklmnopqrstuvwxyz0123456789#!$%^&*()-=\\[];'`,./"
rnd = srand()