Class: OpenCL::Version

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

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

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.



147
148
149
150
151
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 147

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.



146
147
148
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 146

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



146
147
148
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 146

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



146
147
148
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 146

def patch
  @patch
end

Class Method Details

.from_int(v) ⇒ Object



187
188
189
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 187

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

.major(v) ⇒ Object



169
170
171
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 169

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

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



181
182
183
184
185
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 181

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



173
174
175
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 173

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

.patch(v) ⇒ Object



177
178
179
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 177

def self.patch(v)
  v & PATCH_MASK
end

Instance Method Details

#<=>(other) ⇒ Object



158
159
160
161
162
163
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 158

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



153
154
155
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 153

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

#to_sObject



165
166
167
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 165

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