ruby drb
client.rb
======================================================================
require 'drb'
SERVER_IP = 'druby://127.0.0.1:6666'
CLIENT_IP = 'druby://10.10.10.102:7777'
c_path = 'd:/test/'
class Client
def initialize(path)
Dir.chdir(path)
end
def mkdir(path)
begin
Dir.mkdir(path)
rescue
p 'the path : ' +path+" already exist !!!"
end
end
def mkfile(path,text)
f = File.open(path , 'w+')
f.write(text)
f.close
end
def file?(path)
return File.file?(path)
end
def get_file_text(path)
file = File.open(path)
text= file.read
file.close
return text
end
def check_in(dir,obj)
if file?(dir)
obj.mkfile(dir,get_file_text(dir))
else
obj.mkdir(dir)
for f in d = Dir.open(dir)
fp = File.join(dir,f)
if f != '.' and f != '..'
if File.directory?(fp)
obj.mkdir(fp)
check_in(fp,obj)
else
obj.mkfile(fp,get_file_text(fp))
end
end
end
end
end
def check_out()
end
end
client = Client.new(c_path)
DRb.start_service(CLIENT_IP,client)
server_obj = DRbObject.new(nil,SERVER_IP)
#client.check_in('wei/',server_obj)
#server_obj.check_in('wei/file.txt',CLIENT_IP)
server_obj.check_out('wei/' ,CLIENT_IP )
DRb.stop_service
server.rb
===============================================================================
# service
require 'drb'
SERVER_IP = '
Ïà¹ØÎĵµ£º
Á½ÖÖ²»Í¬µÄÓïÑÔ,²»Í¬µÄ±í´ï!
Python½Å±¾ÊµÏÖ.
""
"
File Name : clean.py
File Date : 2009/11/5 14:22:56
Author : DannyLai
Purpose : Cle ......
ÉÏÉÏÖÜÔÚÊéµê¿´µ½Ò»±¾¡¶Ruby
Éè¼ÆÄ£Ê½¡·£¬¼ñÆðÀ´ 10 ·ÖÖÓ¿´Í꣬ÈÓÁË£¨±ðÎÊÎÒΪʲô……£©
ÏÂÃæÓÃ Ruby
ддÉè¼ÆÄ£Ê½£¬Ë³±ãÅúÒ»Åú Java ºÍ Gof
¡£
1.Factory
ºÍ Abstract Factory
class
Factory
attr_accessor :product
......
Ëɱ¾ÐкêÈçÔ¼ÓÚÊ¥µ®½Ú·¢²¼ÁËRuby 1.9¡£¸ù¾ÝRubyµÄ¹ßÀý£¬Ð¡ÊýµãºóÃæµÚһλÈç¹ûÊǵ¥Êý£¬ÄÇô¾Í±íÃ÷ÕâÊÇÒ»¸öʵÑé°æ±¾£¬²»ÍƼöÓÃÓÚ²úÆ·»·¾³¡£Ëùν“²úÆ·»·¾³”£¬¶ÔÓÚĿǰµÄRubyÀ´Ëµ£¬»ù±¾ÉϾÍÊÇRuby on Rails¡£´ÓĿǰRoRÉçȺµÄ·´Ó³À´¿´£¬È·ÊµÓÐÈËÕýÔÚ³¢ÊÔÓÃRuby 1.9ÅäºÏRoR£¬µ«ÊÇÉÐÊôÍæÆ±ÐÔÖÊ¡£ÎÒѯÎÊÁËһЩ´¦ÔÚÕæÊµÏ ......
Ruby 101£º·½·¨¶ÔÏó
Written by Allen Lee
´Ó·½·¨µ÷ÓÃ˵Æð
ÔÚÉÏһƪÎÄÕÂÀÎÒÃÇ¿´µ½µ÷ÓöÔÏóµÄ·½·¨ÊµÖÊÉÏÊÇÏò¶ÔÏó·¢ËÍÏûÏ¢£¬ÏÂÃæ£¬ÎÒÃÇÔÙÀ´¿´Ò»¸öÓÐȤµÄÓ¦Óá£ÔÚRubyÀ×Öµä¿ÉÒÔͨ¹ý {key => value} À´´´½¨£¬Èç¹ûÄãʹÓõİ汾ÊÇ1.9»òÒÔÉÏ£¬µ±keyµÄÀàÐÍÊÇSymbolʱ£¬´´½¨×ÖµäµÄÓ ......
×î½üÔÚ¿´John E.Hopcroft,Rajeev Motwani,Jeffrey D.Ullman Èý¾ÞͷдµÄIntroduction to Automata Theory,Language,and Computation£¬Ïëдһ¸öTuring »úÑéÖ¤Ò»ÏÂ×Ô¼ºÐ´µÄ×´Ì¬×ªÒÆº¯Êý¶Ô²»¶Ô¡£ÀÁµÃºÜ£¬ÍøÉÏËÑÁ˼¸¸ö²»´íµÄ¡£µ«Ruby Quiz ÉϵÄÕâ¸ö×î¼òµ¥¡£
162 Turing »ú
ÎÊÌâÃèÊö
Quiz
description by James Edward Gray ......