Class: File
- Defined in:
- lib/sane/sane_random.rb,
lib/sane/bugs.rb,
lib/sane/bugs.rb,
lib/sane/file.rb,
lib/sane/file_filename.rb
Overview
abstracted from require ‘facets/file’ ===>
Class Method Summary collapse
- .basename(*args) ⇒ Object (also: filename)
- .binread(filename) ⇒ Object
- .binwrite(path, data) ⇒ Object
- .executable?(*args) ⇒ Boolean
- .original_basename ⇒ Object
-
.write(path, data) ⇒ Object
Writes the given data to the given path and closes the file.
Class Method Details
.basename(*args) ⇒ Object Also known as: filename
20 21 22 |
# File 'lib/sane/bugs.rb', line 20 def File.basename *args original_basename(*args).dup end |
.binread(filename) ⇒ Object
2 3 4 |
# File 'lib/sane/file.rb', line 2 def self.binread filename File.open(filename, 'rb')do |f| f.read; end end |
.binwrite(path, data) ⇒ Object
24 25 26 27 28 |
# File 'lib/sane/sane_random.rb', line 24 def self.binwrite(path, data) File.open(path, "wb") do |file| return file.write(data) end end |
.executable?(*args) ⇒ Boolean
7 8 9 |
# File 'lib/sane/bugs.rb', line 7 def executable? *args File.stat(*args).executable? rescue nil end |
.original_basename ⇒ Object
19 |
# File 'lib/sane/bugs.rb', line 19 alias :original_basename :basename |
.write(path, data) ⇒ Object
Writes the given data to the given path and closes the file. This is done in binary mode, complementing IO.read in standard Ruby.
Returns the number of bytes written.
CREDIT: facets/Gavin Sinclair
18 19 20 21 22 |
# File 'lib/sane/sane_random.rb', line 18 def self.write(path, data) File.open(path, "w") do |file| return file.write(data) end end |