본문 바로가기
Programming

Ruby File copy

by leanu 2010. 7. 22.

1.8 에서 1.9 로 넘어오면서 왜이리 많이 바뀐겨...
레퍼런스에 설명도 잘 안되있어서... 

1.9 로 넘어오면서 ftools 에 있는 내용들이 거의 fileutils 로 통폐합 되었고, 사용법 일부가 바뀌었다.
버전별 require 나 사용 Class 를 바꾸고 싶은경우 RUBY_VERSION 을 이용하면 좋다.

Error : undefined method `copy' for File:Class (NoMethodError)
Version 1.8
 
require 'ftools'
 
File.copy(src, tar)
Version 1.9.1
 
require 'fileutils'
 
FileUtils.copy(src, tar)

댓글