Class: Zinzout::ZinFile

Inherits:
Object
  • Object
show all
Defined in:
lib/zinzout.rb

Direct Known Subclasses

ZoutFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, encoding) ⇒ ZinFile

Returns a new instance of ZinFile.



53
54
55
# File 'lib/zinzout.rb', line 53

def initialize(filename, encoding)
  @io = io_from_file(filename, encoding)
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



51
52
53
# File 'lib/zinzout.rb', line 51

def io
  @io
end

Instance Method Details

#closeObject



63
64
65
# File 'lib/zinzout.rb', line 63

def close
  @io.close
end

#io_from_file(filename, encoding) ⇒ Object



57
58
59
60
61
# File 'lib/zinzout.rb', line 57

def io_from_file(filename, encoding)
  Zlib::GzipReader.open(filename, encoding: encoding)
rescue Zlib::GzipFile::Error
  ::File.open(filename, 'r', encoding: encoding)
end