Class: OpenCL::LUID
- Defined in:
- lib/opencl_ruby_ffi/khr/device_uuid.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_string(uuid) ⇒ Object
70 71 72 |
# File 'lib/opencl_ruby_ffi/khr/device_uuid.rb', line 70 def self.from_string(uuid) new.from_string(uuid) end |
Instance Method Details
#from_string(uuid) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/opencl_ruby_ffi/khr/device_uuid.rb', line 74 def from_string(uuid) m = uuid.match(/(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)/) raise "invalid format" unless m LUID_SIZE_KHR.times { |i| self[:id][LUID_SIZE_KHR-1-i] = m[i+1].to_i(16) } self end |
#to_s ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/opencl_ruby_ffi/khr/device_uuid.rb', line 57 def to_s a = self[:id].to_a s = "" s << "%02x" % a[7] s << "%02x" % a[6] s << "%02x" % a[5] s << "%02x" % a[4] s << "%02x" % a[3] s << "%02x" % a[2] s << "%02x" % a[1] s << "%02x" % a[0] end |