Class: OpenCL::Enum

Inherits:
Object
  • Object
show all
Defined in:
lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb,
lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb

Overview

A parent class to represent OpenCL enums that use :cl_uint

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ Enum

Initializes an enum with the given val



613
614
615
616
617
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 613

def initialize( val )
  error_check( OpenCL::INVALID_VALUE ) if not self.class.codes[val]
  super()
  @val = val
end

Class Attribute Details

.codesObject (readonly)

Returns the value of attribute codes.



608
609
610
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 608

def codes
  @codes
end

Instance Method Details

#==(val) ⇒ Object

Return true if val corresponds to the enum value



631
632
633
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 631

def ==(val)
  return true if @val == val
end

#coerce(other) ⇒ Object

Enum should be considered an integer



651
652
653
654
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 651

def coerce(other)
  return [other, Pointer::new(self.to_i)] if other.is_a?(Pointer)
  return [other, self.to_i]
end

#inspectObject

Returns a String corresponding to the Enum description



636
637
638
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 636

def inspect
  return "#<#{self.class.name}: #{self.name}>"
end

#is?(val) ⇒ Boolean

Returns true if val corresponds to the enum value

Returns:

  • (Boolean)


626
627
628
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 626

def is?(val)
  return true if @val == val
end

#nameObject

Returns a String representing the Enum value name



646
647
648
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 646

def name
  return self.class.codes[@val]
end

#to_iObject

Returns the integer representing the Enum value



657
658
659
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 657

def to_i
  return @val
end

#to_intObject

Returns the integer representing the Enum value



662
663
664
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 662

def to_int
  return @val
end

#to_sObject

Returns a String corresponfing to the Enum value



641
642
643
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 641

def to_s
  return "#{self.name}"
end

#val=(v) ⇒ Object

Sets the internal value of the enum



620
621
622
623
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 620

def val=(v)
  error_check( OpenCL::INVALID_VALUE ) if not self.class.codes[val]
  @val = v
end