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



637
638
639
640
641
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 637

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.



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

def codes
  @codes
end

Instance Method Details

#==(val) ⇒ Object

Return true if val corresponds to the enum value



655
656
657
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 655

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

#coerce(other) ⇒ Object

Enum should be considered an integer



675
676
677
678
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 675

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



660
661
662
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 660

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

#is?(val) ⇒ Boolean

Returns true if val corresponds to the enum value

Returns:

  • (Boolean)


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

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

#nameObject

Returns a String representing the Enum value name



670
671
672
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 670

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

#to_iObject

Returns the integer representing the Enum value



681
682
683
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 681

def to_i
  return @val
end

#to_intObject

Returns the integer representing the Enum value



686
687
688
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 686

def to_int
  return @val
end

#to_sObject

Returns a String corresponfing to the Enum value



665
666
667
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 665

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

#val=(v) ⇒ Object

Sets the internal value of the enum



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

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