Class: Fzeet::Windows::GUID

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/fzeet/windows/com/Common.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](s) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fzeet/windows/com/Common.rb', line 53

def self.[](s)
	raise 'Bad GUID format.' unless s =~ /^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/i

	new.tap { |guid|
		guid[:Data1] = s[0, 8].to_i(16)
		guid[:Data2] = s[9, 4].to_i(16)
		guid[:Data3] = s[14, 4].to_i(16)
		guid[:Data4][0] = s[19, 2].to_i(16)
		guid[:Data4][1] = s[21, 2].to_i(16)
		s[24, 12].split('').each_slice(2).with_index { |a, i|
			guid[:Data4][i + 2] = a.join('').to_i(16)
		}
	}
end

Instance Method Details

#==(other) ⇒ Object



68
# File 'lib/fzeet/windows/com/Common.rb', line 68

def ==(other) Windows.memcmp(other, self, size) == 0 end