Class: Hdf5::H5File
Overview
Defined Under Namespace
Classes: InvalidFile
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
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) ⇒ H5File
constructor
Open the file with the given filename.
-
#is_hdf5? ⇒ Boolean
Is the file a valid hdf5 file.
Constructor Details
#initialize(filename) ⇒ H5File
Open the file with the given filename. Currently read only
116 117 118 119 120 121 122 |
# File 'lib/hdf5.rb', line 116 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)
Returns the value of attribute id.
114 115 116 |
# File 'lib/hdf5.rb', line 114 def id @id end |
Instance Method Details
#close ⇒ Object
Close the file
128 129 130 |
# File 'lib/hdf5.rb', line 128 def close basic_close(@id) end |
#dataset(name) ⇒ Object
Return a dataset object with the given name (relative to the root of the file)
138 139 140 |
# File 'lib/hdf5.rb', line 138 def dataset(name) return H5Dataset.open(@id, name) end |
#group(name) ⇒ Object
Return a group object with the given name (relative to the root of the file)
133 134 135 |
# File 'lib/hdf5.rb', line 133 def group(name) return H5Group.open(@id, name) end |
#is_hdf5? ⇒ Boolean
Is the file a valid hdf5 file
124 125 126 |
# File 'lib/hdf5.rb', line 124 def is_hdf5? basic_is_hdf5(@filename) > 0 end |