Class: OpenCL::UUID
- 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
41 42 43 |
# File 'lib/opencl_ruby_ffi/khr/device_uuid.rb', line 41 def self.from_string(uuid) new.from_string(uuid) end |
Instance Method Details
#from_string(uuid) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/opencl_ruby_ffi/khr/device_uuid.rb', line 45 def from_string(uuid) m = uuid.match(/(\h\h)(\h\h)(\h\h)(\h\h)-(\h\h)(\h\h)-(\h\h)(\h\h)-(\h\h)(\h\h)-(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)(\h\h)/) raise "invalid format" unless m UUID_SIZE_KHR.times { |i| self[:id][UUID_SIZE_KHR-1-i] = m[i+1].to_i(16) } self end |
#to_s ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/opencl_ruby_ffi/khr/device_uuid.rb', line 16 def to_s a = self[:id].to_a s = "" s << "%02x" % a[15] s << "%02x" % a[14] s << "%02x" % a[13] s << "%02x" % a[12] s << "-" s << "%02x" % a[11] s << "%02x" % a[10] s << "-" s << "%02x" % a[9] s << "%02x" % a[8] s << "-" s << "%02x" % a[7] s << "%02x" % a[6] s << "-" 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 |