Class: Epos::EncodedFile
- Inherits:
-
Object
- Object
- Epos::EncodedFile
- Defined in:
- lib/epos/encoded-file.rb
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #eof? ⇒ Boolean
-
#initialize(path) ⇒ EncodedFile
constructor
A new instance of EncodedFile.
- #read(length = nil) ⇒ Object
- #seek(pos) ⇒ Object
Constructor Details
#initialize(path) ⇒ EncodedFile
Returns a new instance of EncodedFile.
4 5 6 |
# File 'lib/epos/encoded-file.rb', line 4 def initialize(path) @io = File.open(path, "rb") end |
Class Method Details
.read(path, length = nil) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/epos/encoded-file.rb', line 24 def self.read(path, length = nil) file = EncodedFile.new(path) data = file.read(length) file.close return data end |
Instance Method Details
#close ⇒ Object
16 17 18 |
# File 'lib/epos/encoded-file.rb', line 16 def close @io.close end |
#eof? ⇒ Boolean
20 21 22 |
# File 'lib/epos/encoded-file.rb', line 20 def eof? @io.eof? end |
#read(length = nil) ⇒ Object
8 9 10 |
# File 'lib/epos/encoded-file.rb', line 8 def read(length = nil) self.decipher(@io.read(length)).encode("utf-8", "iso-8859-1") end |
#seek(pos) ⇒ Object
12 13 14 |
# File 'lib/epos/encoded-file.rb', line 12 def seek(pos) @io.seek(pos) end |