Class: OMX::OMXFile
- Inherits:
-
Object
- Object
- OMX::OMXFile
- Extended by:
- FFI::Library
- Defined in:
- lib/OpenMatriX.rb
Overview
Object for wrapping an OMX file. Basic usage:
file = OMX::OMXFile.new('filename.omx')
> Do stuff
file.close
Defined Under Namespace
Classes: InvalidFile
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
hid_t H5Aopen( hid_t obj_id, const char *attr_name, hid_t aapl_id ) attach_function :basic_openattr, :H5Aopen, [H5Types.hid_t, :string], H5Types.hid_t.
Instance Method Summary collapse
-
#close ⇒ Object
Close the file.
-
#dataset(name) ⇒ Object
Return a dataset object with the given name (relative to the root of the file).
-
#group(name) ⇒ Object
Return a group object with the given name (relative to the root of the file).
-
#initialize(filename) ⇒ OMXFile
constructor
Open the file with the given filename.
-
#is_hdf5? ⇒ Boolean
Is the file a valid hdf5 file.
Constructor Details
#initialize(filename) ⇒ OMXFile
Open the file with the given filename. Currently read only
143 144 145 146 147 148 149 |
# File 'lib/OpenMatriX.rb', line 143 def initialize(filename) raise Errno::ENOENT.new("File #{filename} does not exist") unless FileTest.exist?(filename) raise InvalidFile.new("File #{filename} is not a valid hdf5 file") unless basic_is_hdf5(filename) > 0 @filename = filename @id = basic_open(filename, 0x0000, 0) raise InvalidFile.new("An unknown problem occured opening #{filename}") if @id < 0 end |
Instance Attribute Details
#id ⇒ Object (readonly)
hid_t H5Aopen( hid_t obj_id, const char *attr_name, hid_t aapl_id ) attach_function :basic_openattr, :H5Aopen, [H5Types.hid_t, :string], H5Types.hid_t
141 142 143 |
# File 'lib/OpenMatriX.rb', line 141 def id @id end |
Instance Method Details
#close ⇒ Object
Close the file
155 156 157 |
# File 'lib/OpenMatriX.rb', line 155 def close basic_close(@id) end |
#dataset(name) ⇒ Object
Return a dataset object with the given name (relative to the root of the file)
165 166 167 |
# File 'lib/OpenMatriX.rb', line 165 def dataset(name) return H5Dataset.open2(@id, name) end |
#group(name) ⇒ Object
Return a group object with the given name (relative to the root of the file)
160 161 162 |
# File 'lib/OpenMatriX.rb', line 160 def group(name) return H5Group.open(@id, name) end |
#is_hdf5? ⇒ Boolean
Is the file a valid hdf5 file
151 152 153 |
# File 'lib/OpenMatriX.rb', line 151 def is_hdf5? basic_is_hdf5(@filename) > 0 end |