Class: File

Inherits:
Object show all
Defined in:
lib/ruco/core_ext/file.rb

Class Method Summary collapse

Class Method Details

.binary_read(file) ⇒ Object

Open files in binary mode. On linux this is ignored by ruby. On Windows ruby open files in text mode by default, so it replaces r with n, so the specs fail. If files are opened in binary mode, which is the only mode on linux, it does not replace the newlines. This thread has slightly more information: groups.google.com/group/rubyinstaller/browse_thread/thread/c7fbe346831e58cc



11
12
13
14
15
16
# File 'lib/ruco/core_ext/file.rb', line 11

def self.binary_read(file)
  io = File.open(file, 'rb')
  content = io.read
  io.close
  content
end

.write(to, content) ⇒ Object



2
3
4
# File 'lib/ruco/core_ext/file.rb', line 2

def self.write(to, content)
  File.open(to, 'wb'){|f| f.write(content) }
end