Class: Hdf5::H5Datatype

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/hdf5.rb

Overview

Object for wrapping an HD5 datatype, which contains information about the type and makeup of an individual element of the dataset, which may be a float or integer, or may be a vast compound type

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ H5Datatype

Returns a new instance of H5Datatype.



311
312
313
314
# File 'lib/hdf5.rb', line 311

def initialize(id)
  ObjectSpace.define_finalizer(self){H5Datatype.basic_close(id)}
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



310
311
312
# File 'lib/hdf5.rb', line 310

def id
  @id
end

Instance Method Details

#h5_classObject



315
316
317
# File 'lib/hdf5.rb', line 315

def h5_class
  basic_get_class(@id)
end

#is_complex?Boolean

We assume that a compound datatype with two floating point members is a complex number. This may want to be revisisted…

Returns:

  • (Boolean)


324
325
326
# File 'lib/hdf5.rb', line 324

def is_complex?
  nmembers == 2 and member_types.map{|t| t.h5_class} == [:h5t_float, :h5t_float]
end

#member_typesObject

An array of datatypes of the members of a compound datatype



328
329
330
# File 'lib/hdf5.rb', line 328

def member_types
  nmembers.times.map{|i| self.class.new(basic_get_member_type(@id, i))}
end

#nmembersObject

The number of members in a compound datatype



319
320
321
# File 'lib/hdf5.rb', line 319

def nmembers
  basic_get_nmembers(@id)
end