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 = '
Ïà¹ØÎĵµ£º
·ÖΪÈçϼ¸½Ú:
·»ù±¾ÊµÏÖ
·ÔÚµü´úÖÐÒýÓÃÔÀ´µÄ¶ÔÏ󣬻òÕßÖ±½Ó¸Ä±äÊý×éµÄÖµ¶ø²»ÊÇ·µ»ØÒ»¸öÐÂÊý×é
·Ïòµü´ú´«ÈëÎÞÏÞ¶àµÄ²ÎÊý
·»ù±¾ÊµÏÖ
½ñÌìͻȻ·¢ÏÖjsµÄÊý×é´¦ÀíÆðÀ´ÕæÊÇÂé·³,´úÂëһЩ¾ÍÊÇÒ»´ó¶Ñ,Ïà±ÈÆðrubyµÄµü´úÆ÷À´ÕæÊÇÑ·É«²»ÉÙ,Ö÷ÒªÊÇҪдµÄ´úÂëÌ«¶àÁË,Ò²ÐíÊÇjsÓÐÌØÊâµÄ´¦ÀíÊý×éµÄ·½Ê ......
ÓÃrubyн¨Ò»¸öexcelÎļþ£¬²¢ÇÒÉèÖÃһЩֵ¡£
require 'win32ole'
excel = WIN32OLE.new("excel.application")
excel.Visible = true
excel.WorkBooks.Open("d:\\test.xls")
excel.WorkSheets("sheet1").Activate
excel.Cells(2,3).value = "ÕÅÈý"
exce ......
def delVss(path)
if File.directory?(path)
for f in d = Dir.open(path)
fpath = File.join(path, f)
if(f!="."&&f!="..")
......
ÉÏÉÏÖÜÔÚÊéµê¿´µ½Ò»±¾¡¶Ruby
Éè¼Æģʽ¡·£¬¼ñÆðÀ´ 10 ·ÖÖÓ¿´Í꣬ÈÓÁË£¨±ðÎÊÎÒΪʲô……£©
ÏÂÃæÓÃ Ruby
ддÉè¼Æģʽ£¬Ë³±ãÅúÒ»Åú Java ºÍ Gof
¡£
1.Factory
ºÍ Abstract Factory
class
Factory
attr_accessor :product
......
While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file c ......