显示标签为“The Ruby Way”的博文。显示所有博文
显示标签为“The Ruby Way”的博文。显示所有博文

2009年4月29日星期三

Ruby:string to date Or date to string

Ruby:string to date Or date to string
#string to date:
str="2009-02-02"
date=Date.strptime(str,"%Y-%m-%d")
#date to string:
date=Date.new(2009,2,2)
str=date.strftime("%Y-%m-%d")

2009年4月22日星期三

Ruby 递归删除文件目录

递归删除文件目录:
require 'pathname'
dir=Pathname.new("/home/poole/")
dir.rmtree

#or

require 'fileutils'
FileUtils.rm_r("/home/poole")