mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* sample/drb/README.rd.ja:
* sample/drb/dhasenc.rb: * sample/mine.rb: Change encoding from EUC-JP to UTF-8 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
05558e04b8
commit
d53e9c1e84
4 changed files with 54 additions and 47 deletions
|
@ -1,3 +1,10 @@
|
|||
Thu Sep 9 01:14:00 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* sample/drb/README.rd.ja:
|
||||
* sample/drb/dhasenc.rb:
|
||||
* sample/mine.rb:
|
||||
Change encoding from EUC-JP to UTF-8
|
||||
|
||||
Thu Sep 8 21:03:22 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* ext/nkf/nkf-utf8/nkf.c: import nkf 2.1.2 (be9c280)
|
||||
|
|
|
@ -1,59 +1,59 @@
|
|||
= サンプルスクリプト
|
||||
= サンプルスクリプト
|
||||
|
||||
* Arrayをリモートから利用してイテレータを試す。
|
||||
* Arrayをリモートから利用してイテレータを試す。
|
||||
* darray.rb --- server
|
||||
* darrayc.rb --- client
|
||||
|
||||
* 簡易チャット
|
||||
* 簡易チャット
|
||||
* dchats.rb --- server
|
||||
* dchatc.rb --- client
|
||||
|
||||
* 分散chasen
|
||||
* 分散chasen
|
||||
* dhasen.rb --- server
|
||||
* dhasenc.rb --- client
|
||||
|
||||
* 簡易ログサーバ
|
||||
* 簡易ログサーバ
|
||||
* dlogd.rb --- server
|
||||
* dlogc.rb --- client
|
||||
|
||||
* Queueサーバ。
|
||||
クライアントdqin.rbはQueueサーバの知らないオブジェクト(DQEntry)を
|
||||
pushするがDRbUnknownによりクライアントdqout.rbがpopできる。
|
||||
* Queueサーバ。
|
||||
クライアントdqin.rbはQueueサーバの知らないオブジェクト(DQEntry)を
|
||||
pushするがDRbUnknownによりクライアントdqout.rbがpopできる。
|
||||
* dqueue.rb --- server
|
||||
* dqin.rb --- client。DQEntryオブジェクトをpushする
|
||||
* dqout.rb --- client。DQEntryオブジェクトをpopする
|
||||
* dqlib.rb --- DQEntryを定義したライブラリ
|
||||
* dqin.rb --- client。DQEntryオブジェクトをpushする
|
||||
* dqout.rb --- client。DQEntryオブジェクトをpopする
|
||||
* dqlib.rb --- DQEntryを定義したライブラリ
|
||||
|
||||
* 名前による参照
|
||||
IdConvをカスタマイズしてidでなく名前で参照する例
|
||||
* 名前による参照
|
||||
IdConvをカスタマイズしてidでなく名前で参照する例
|
||||
* name.rb --- server
|
||||
* namec.rb --- client
|
||||
|
||||
* extservのサンプル
|
||||
* extservのサンプル
|
||||
* extserv_test.rb
|
||||
|
||||
* TimerIdConvの使用例
|
||||
* holders.rb --- server。ruby -d hodlers.rbとするとTimerIdConvを使用する。
|
||||
* TimerIdConvの使用例
|
||||
* holders.rb --- server。ruby -d hodlers.rbとするとTimerIdConvを使用する。
|
||||
* holderc.rb --- client
|
||||
|
||||
* rinda.rbの使用例
|
||||
* rinda_ts.rb --- TupleSpaceサーバ。
|
||||
* rindac.rb --- TupleSpaceのclientでアプリケーションのclient
|
||||
* rindas.rb --- TupleSpaceのclientでアプリケーションのserver
|
||||
* rinda.rbの使用例
|
||||
* rinda_ts.rb --- TupleSpaceサーバ。
|
||||
* rindac.rb --- TupleSpaceのclientでアプリケーションのclient
|
||||
* rindas.rb --- TupleSpaceのclientでアプリケーションのserver
|
||||
|
||||
* observerの使用例
|
||||
* observerの使用例
|
||||
cdbiff - ((<URI:http://namazu.org/~satoru/cdbiff/>))
|
||||
* dbiff.rb --- dcdbiff server
|
||||
* dcdbiff.rb --- dcdbiff client
|
||||
|
||||
* drbsslの使用例
|
||||
* drbsslの使用例
|
||||
* drbssl_s.rb
|
||||
* drbssl_c.rb
|
||||
|
||||
* DRbProtoclの追加例
|
||||
* DRbProtoclの追加例
|
||||
* http0.rb
|
||||
* http0serv.rb
|
||||
|
||||
* ringの使用例
|
||||
* ringの使用例
|
||||
* ring_place.rb
|
||||
* ring_echo.rb
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# -*- encoding: euc-jp -*-
|
||||
# -*- encoding: utf-8 -*-
|
||||
=begin
|
||||
distributed Ruby --- dRuby Sample Client -- chasen client
|
||||
Copyright (c) 1999-2001 Masatoshi SEKI
|
||||
|
@ -10,5 +10,5 @@ there = ARGV.shift || raise("usage: #{$0} <server_uri>")
|
|||
DRb.start_service
|
||||
dhasen = DRbObject.new(nil, there)
|
||||
|
||||
print dhasen.sparse("本日は、晴天なり。", "-F", '(%BB %m %M)\n', "-j")
|
||||
print dhasen.sparse("本日は、晴天なり。", "-F", '(%m %M)\n')
|
||||
print dhasen.sparse("本日は、晴天なり。", "-F", '(%BB %m %M)\n', "-j")
|
||||
print dhasen.sparse("本日は、晴天なり。", "-F", '(%m %M)\n')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#! /usr/bin/ruby -Ke
|
||||
# -*- encoding: euc-jp -*-
|
||||
#! /usr/bin/ruby -Ku
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
class Board
|
||||
def clr
|
||||
|
@ -13,19 +13,19 @@ class Board
|
|||
end
|
||||
def put(x, y, col, str)
|
||||
pos(x,y); colorstr(43,str)
|
||||
pos(0,@hi); print "残り:",@mc,"/",@total," "
|
||||
pos(0,@hi); print "残り:",@mc,"/",@total," "
|
||||
pos(x,y)
|
||||
end
|
||||
private :clr, :pos, :colorstr, :put
|
||||
CHR=["・","1","2","3","4","5","6","7","8","★","●","@@"]
|
||||
CHR=["・","1","2","3","4","5","6","7","8","★","●","@@"]
|
||||
COL=[46,43,45] # default,opened,over
|
||||
def initialize(h,w,m)
|
||||
# ゲーム盤の生成(h:縦,w:横,m:爆弾の数)
|
||||
# ゲーム盤の生成(h:縦,w:横,m:爆弾の数)
|
||||
@hi=h; @wi=w; @m=m
|
||||
reset
|
||||
end
|
||||
def reset
|
||||
# ゲーム盤を(再)初期化する
|
||||
# ゲーム盤を(再)初期化する
|
||||
srand()
|
||||
@cx=0; @cy=0; @mc=@m
|
||||
@over=false
|
||||
|
@ -47,7 +47,7 @@ class Board
|
|||
pos(@cx,@cy)
|
||||
end
|
||||
def mark
|
||||
# 現在のカーソル位置にマークをつける
|
||||
# 現在のカーソル位置にマークをつける
|
||||
if @state[@wi*@cy+@cx] != nil then return end
|
||||
@state[@wi*@cy+@cx] = "MARK"
|
||||
@mc=@mc-1;
|
||||
|
@ -55,8 +55,8 @@ class Board
|
|||
put(@cx, @cy, COL[1], CHR[9])
|
||||
end
|
||||
def open(x=@cx,y=@cy)
|
||||
# 現在のカーソル位置をオープンにする
|
||||
# 爆弾があればゲームオーバー
|
||||
# 現在のカーソル位置をオープンにする
|
||||
# 爆弾があればゲームオーバー
|
||||
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
|
||||
|
@ -76,7 +76,7 @@ class Board
|
|||
pos(@cx,@cy)
|
||||
end
|
||||
def fetch(x,y)
|
||||
# (x,y)の位置の爆弾の数(0 or 1)を返す
|
||||
# (x,y)の位置の爆弾の数(0 or 1)を返す
|
||||
if x < 0 then 0
|
||||
elsif x >= @wi then 0
|
||||
elsif y < 0 then 0
|
||||
|
@ -86,13 +86,13 @@ class Board
|
|||
end
|
||||
end
|
||||
def count(x,y)
|
||||
# (x,y)に隣接する爆弾の数を返す
|
||||
# (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)
|
||||
# ゲームの終了
|
||||
# ゲームの終了
|
||||
quit
|
||||
unless win
|
||||
pos(@cx,@cy); print CHR[11]
|
||||
|
@ -103,8 +103,8 @@ class Board
|
|||
end
|
||||
end
|
||||
def over?
|
||||
# ゲームの終了チェック
|
||||
# 終了処理も呼び出す
|
||||
# ゲームの終了チェック
|
||||
# 終了処理も呼び出す
|
||||
remain = (@mc+@total == 0)
|
||||
if @over || remain
|
||||
over(remain)
|
||||
|
@ -114,8 +114,8 @@ class Board
|
|||
end
|
||||
end
|
||||
def quit
|
||||
# ゲームの中断(または終了)
|
||||
# 盤面を全て見せる
|
||||
# ゲームの中断(または終了)
|
||||
# 盤面を全て見せる
|
||||
@hi.times do|y|
|
||||
pos(0,y)
|
||||
@wi.times do|x|
|
||||
|
@ -125,19 +125,19 @@ class Board
|
|||
end
|
||||
end
|
||||
def down
|
||||
# カーソルを下に
|
||||
# カーソルを下に
|
||||
if @cy < @hi-1 then @cy=@cy+1; pos(@cx, @cy) end
|
||||
end
|
||||
def up
|
||||
# カーソルを上に
|
||||
# カーソルを上に
|
||||
if @cy > 0 then @cy=@cy-1; pos(@cx, @cy) end
|
||||
end
|
||||
def left
|
||||
# カーソルを左に
|
||||
# カーソルを左に
|
||||
if @cx > 0 then @cx=@cx-1; pos(@cx, @cy) end
|
||||
end
|
||||
def right
|
||||
# カーソルを右に
|
||||
# カーソルを右に
|
||||
if @cx < @wi-1 then @cx=@cx+1; pos(@cx, @cy) end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue