Class: Wiris::File
- Inherits:
-
File
- Object
- File
- Wiris::File
- Defined in:
- lib/src-generic/File.rb
Class Method Summary collapse
- .getBytes(file) ⇒ Object
- .getContent(file) ⇒ Object
- .saveBytes(file, b) ⇒ Object
- .saveContent(file, str) ⇒ Object
- .write(str, binary) ⇒ Object
Class Method Details
.getBytes(file) ⇒ Object
17 18 19 |
# File 'lib/src-generic/File.rb', line 17 def self.getBytes(file) return Bytes.new(IO.binread(file).unpack("C*")) end |
.getContent(file) ⇒ Object
21 22 23 |
# File 'lib/src-generic/File.rb', line 21 def self.getContent(file) return File.read(file) end |
.saveBytes(file, b) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/src-generic/File.rb', line 9 def self.saveBytes(file, b) File.open(file, 'wb' ) do |output| b.bytes.each do | byte | output.print byte.chr end end end |
.saveContent(file, str) ⇒ Object
3 4 5 6 7 |
# File 'lib/src-generic/File.rb', line 3 def self.saveContent(file, str) out = write(file, true); out.write(str) out.close end |
.write(str, binary) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/src-generic/File.rb', line 25 def self.write(str, binary) if (!binary) raise Exception,"Only binary files allowed!" end return File.open(str, 'wb') end |