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

ruby文件操作

1、文件的打开与关闭
    ``r'' Read-only, starts at beginning of file (default mode).
    ``r+'' Read-write, starts at beginning of file.
    ``w'' Write-only, truncates existing file to zero length or creates a new file for writing.
    ``w+'' Read-write, truncates existing file to zero length or creates a new file for reading and writing.
    ``a'' Write-only, starts at end of file if file exists, otherwise creates a new file for writing.
    ``a+'' Read-write, starts at end of file if file exists, otherwise creates a new file for reading and writing.
    ``b'' (DOS/Windows only) Binary file mode (may appear with any of the key letters listed above).
     使用file.new方法获取一个文件句柄来对文件操作,操作结束后file.close来关闭文件。
     file.open方法是new方法的扩充,该方法可有代码块,该代码块结束后自动close,而且在操作过程中发生错误时能够自动收集错误并推出
    如    
    file.open("filepath") do |file|
        file.each do |line| ... end
    end
    一些文件的常用命令:
    File.open(dir+"/read.txt","w") do |file|
    file.puts("djkjsadlkjdkdsfdsee")
end puts File.exists?(dir+"/read.txt")       文件是否存在
puts File.directory?(dir+"/read.txt")    文件是否是目录路径
puts File.file?(dir+"/read.txt")        是否是文件
puts File.zero?(dir+"/read.txt")        文件内容长度是否为0
puts File.size(dir+"/read.txt")        获取文件大小
put


相关文档:

Ruby都从Perl那继承了什么?


最近看了看Perl,主要是想看看Ruby都从Perl那拿来了些什么。同时,也是我学习Perl的一篇笔记。
为什么大家都是Perl的代码丑陋,是什么导致了Perl程序晦涩难懂,Ruby中又是如何取舍这些元素的呢?我认为Perl社区追求更少代码的风气助长了大量使用预设变量的风气,从而导致了Perl代码的晦涩。
下面的每个Perl的例子总伴有 ......

ruby 应用

1:FXRuby is a library for developing powerful and sophisticated cross-platform graphical user interfaces (GUIs) for your Ruby applications. It’s based on the FOX Toolkit, a popular open source C++ library developed by Jeroen van der Zijp. What that means for you as an application developer is that ......

RUBY 实现SOAP

SOAP 服务端:
#!/usr/local/bin/ruby
require 'soap/rpc/standaloneServer'
module MySOAP
 class Timer
  def now
   Time.new.strftime("%Y-%m-%d %H:%M:%S")
  end
 end
 class Add
   def add(i, j)
  return i.to_i + j.to_i
&nb ......

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

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

删除工程中svn文件的脚本(Ruby版和Python版)

两种不同的语言,不同的表达!
Python脚本实现.
""
"
    File Name : clean.py
    File Date : 2009/11/5 14:22:56
    Author     : DannyLai
    Purpose     : Cle ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号