易截截图软件、单文件、免安装、纯绿色、仅160KB

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 = '


相关文档:

清楚VSS文件的批处理(Ruby版)

 
def delVss(path)
  if File.directory?(path)
    for f in d = Dir.open(path)
        fpath = File.join(path, f) 
      if(f!="."&&f!="..")      
    ......

ubuntu下搭建ruby on rails

 一 安装ruby
$sudo apt-get install ruby irb rdoc
二 安装gem
1.到这里下载 ,最好是最新版本,我的1.3.5
解压,切换到当前目录,执行$sudo ruby setup.rb
或者这样:
$ tar xzvf rubygems-1.3.5.tgz   (解压)
$ cd rubygems-1.3.5     (切换到此目录)
$ sudo ruby setup ......

用 Ruby 踩踩四人帮




上上周在书店看到一本《Ruby
设计模式》,捡起来 10 分钟看完,扔了(别问我为什么……)
下面用 Ruby
写写设计模式,顺便批一批 Java 和 Gof

1.Factory
和 Abstract Factory
class
 Factory  
  attr_accessor :product
   ......

Ruby快速入门(二):变量

上一篇文章
说了Ruby的安装和运行,也简单的说了下类和对象。这里主要谈谈变量的问题。
先说常量
。如果变量名以大写字母开头,就被视为常量,但通常是所有字母都大写。但和其他语言不同,在Ruby中,你仍然可以改变常量的值,当然解释器会抛出一个警告:
#! /usr/bin/ruby
CONSTANT = 1
print "#{CONSTANT}\n&qu ......

c++中调用ruby代码

#include < ruby.h > //
static int id_sum;
int Values[] = {5, 10 ,15,-1,20,0};
static VALUE wrap_sum(VALUE args)
{
 VALUE * values = (VALUE *) args;
 VALUE summer = values[0]; 
 VALUE max = values[1];
 return rb_funcall(summer,id_sum,1,max);
}
static VALUE ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号