易截截图软件、单文件、免安装、纯绿色、仅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学习网络资源

英文资源:
http://www.ruby-lang.org/
http://www.ruby-doc.org(访问不到可用下面的网址访问):
http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.ruby-doc.org
http://rubyforge.org/
http://www.ruby-forum.org/bb
http://www.rubygarden.org/ruby
http://www.rubyxml.com/
http://www.pragmaticprogra ......

Ruby打包发布

http://www.erikveen.dds.nl/distributingrubyapplications/rails.html:
In this tutorial, we'll go through the following steps: Setup the environment Create the SQLite database Develop the Rails application Create the RBA (= Ruby archive) from the application with Tar2RubyScript ......

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 & rails

rails
  Rails框架首次提出是在2004年7月,它的研发者是26岁的丹麦人David Heinemeier Hansson。不同于已有复杂的Web 开发框架,Rails是一个更符合实际需要而且更高效的Web开发框架。Rails结合了PHP体系的优点(快速开发)和Java体系的优点(程序规整),因此,Rails在其提出后不长的时间里就受到了业内广泛的关注。
  ......

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

 
def delVss(path)
  if File.directory?(path)
    for f in d = Dir.open(path)
        fpath = File.join(path, f) 
      if(f!="."&&f!="..")      
    ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号