Class: OpenCL::Version

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(major, minor = 0, patch = 0) ⇒ Version

Returns a new instance of Version.



261
262
263
264
265
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 261

def initialize(major, minor = 0, patch = 0)
  @major = major
  @minor = minor
  @patch = patch
end

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



260
261
262
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 260

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



260
261
262
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 260

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



260
261
262
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 260

def patch
  @patch
end

Class Method Details

.from_int(v) ⇒ Object



301
302
303
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 301

def self.from_int(v)
  self.new(major(v), minor(v), patch(v))
end

.major(v) ⇒ Object



283
284
285
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 283

def self.major(v)
  v >> (MINOR_BITS + PATCH_BITS)
end

.make(major, minor = 0, patch = 0) ⇒ Object



295
296
297
298
299
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 295

def self.make(major, minor = 0, patch = 0)
  ((major & MAJOR_MASK) << (MINOR_BITS + PATCH_BITS)) +
  ((minor & MINOR_MASK) << PATCH_BITS) +
   (patch & PATCH_MASK)
end

.minor(v) ⇒ Object



287
288
289
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 287

def self.minor(v)
  (v >> (PATCH_BITS)) & MINOR_MASK
end

.patch(v) ⇒ Object



291
292
293
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 291

def self.patch(v)
  v & PATCH_MASK
end

Instance Method Details

#<=>(other) ⇒ Object



272
273
274
275
276
277
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 272

def <=>(other)
  res = (@major <=> other.major)
  res = (@minor <=> other.minor) if res == 0
  res = (@patch <=> other.patch) if res == 0
  res
end

#to_intObject Also known as: to_i



267
268
269
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 267

def to_int
  Version.make(@major, @minor, @patch)
end

#to_sObject



279
280
281
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 279

def to_s
  "#{@major}.#{@minor}.#{@patch}"
end

Constant Summary collapse

MAJOR_BITS =
10
MINOR_BITS =
10
PATCH_BITS =
12
MAJOR_MASK =
(1 << MAJOR_BITS) - 1
MINOR_MASK =
(1 << MINOR_BITS) - 1
PATCH_MASK =
(1 << PATCH_BITS) - 1