Class: OpenCL::Version
- Inherits:
-
Object
- Object
- OpenCL::Version
- Includes:
- Comparable
- Defined in:
- lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
Class Method Summary collapse
- .from_int(v) ⇒ Object
- .major(v) ⇒ Object
- .make(major, minor = 0, patch = 0) ⇒ Object
- .minor(v) ⇒ Object
- .patch(v) ⇒ Object
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(major, minor = 0, patch = 0) ⇒ Version
constructor
A new instance of Version.
- #to_int ⇒ Object (also: #to_i)
- #to_s ⇒ Object
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
#major ⇒ Object (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 |
#minor ⇒ Object (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 |
#patch ⇒ Object (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_int ⇒ Object 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_s ⇒ Object
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