Class: Hornetseye::BOOL

Inherits:
Element show all
Defined in:
lib/multiarray/bool.rb

Overview

Class for representing native booleans

Defined Under Namespace

Modules: Match

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

coercion, #compilable?, construct, #descriptor, #dup, #get, #initialize, #skip, #store, #strip, #values

Methods inherited from Node

===, #[], #[]=, #array_type, array_type, basetype, #basetype, bool, byte, #check_shape, #coerce, coercion_bool, coercion_byte, coercion_maxint, #compilable?, compilable?, cond, contiguous, #decompose, #demand, #descriptor, dimension, #dimension, #dup, empty?, #empty?, #finalised?, finalised?, float, float_scalar, floating, #force, #get, height, #height, indgen, #inspect, match, maxint, #memory, #pointer_type, pointer_type, rgb?, #rgb?, scalar, #shape, shape, #simplify, size, #size, #storage_size, strip, #strip, subst, #subst, #to_a, #to_s, to_s, to_type, #typecode, typecode, typecodes, variables, #variables, #width, width

Methods included from FLOAT_::Match

#align, #fit

Methods included from OBJECT::Match

#align, #fit

Methods included from COMPLEX_::Match

#align, #fit

Methods included from Sequence_::Match

#align, #fit

Methods included from Match

#fit

Methods included from RGB_::Match

#align, #fit

Methods included from INT_::Match

#fit

Methods included from Operations

#+@, #<=>, #b=, #b_with_decompose, #collect, #conditional, #convolve, define_binary_op, define_unary_op, #diagonal, #eq_with_multiarray, #fill!, #g=, #g_with_decompose, #histogram, #histogram_with_composite, #imag=, #imag_with_decompose, #inject, #integral, #lut, #lut_with_composite, #max, #min, #normalise, #product, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #roll, #sum, #to_type, #to_type_with_rgb, #transpose, #unroll

Constructor Details

This class inherits a constructor from Hornetseye::Element

Class Method Details

.defaultObject

Get default value for elements of this type

Returns:



79
80
81
# File 'lib/multiarray/bool.rb', line 79

def default
  false
end

.descriptor(hash) ⇒ String

Get unique descriptor of this class

Parameters:

  • hash (Hash)

    Labels for any variables.

Returns:

  • (String)

    Descriptor of this class.



39
40
41
# File 'lib/multiarray/bool.rb', line 39

def descriptor( hash )
  inspect
end

.directiveString

Directive for packing/unpacking elements of this type

Returns:

  • (String)

    Returns ‘c’.



88
89
90
# File 'lib/multiarray/bool.rb', line 88

def directive
  'c'
end

.fetch(ptr) ⇒ BOOL

Retrieve element from memory

Parameters:

  • ptr (Malloc)

    Memory to load element from.

Returns:

  • (BOOL)

    Result of fetch operation.

See Also:



52
53
54
# File 'lib/multiarray/bool.rb', line 52

def fetch( ptr )
  new ptr.load( self ).first.ne( 0 )
end

.inspectString

Get string with information about this class

Returns:

  • (String)

    Returns ‘BOOL’



28
29
30
# File 'lib/multiarray/bool.rb', line 28

def inspect
  'BOOL'
end

.memoryClass

Memory type required to store elements of this type

Returns:

  • (Class)

    Returns Malloc.



61
62
63
# File 'lib/multiarray/bool.rb', line 61

def memory
  Malloc
end

.storage_sizeInteger

Get storage size to store an element of this type

Returns:

  • (Integer)

    Returns 1.



70
71
72
# File 'lib/multiarray/bool.rb', line 70

def storage_size
  1
end

Instance Method Details

#write(ptr) ⇒ BOOL

Write element to memory

Parameters:

  • ptr (Malloc)

    Memory to write element to.

Returns:

  • (BOOL)

    Returns self.

See Also:



103
104
105
106
# File 'lib/multiarray/bool.rb', line 103

def write( ptr )
  ptr.save UBYTE.new( get.conditional( 1, 0 ) )
  self
end