Class: Guid
Constant Summary
Constants included
from Guid_Win32_
Guid_Win32_::CRYPT_VERIFYCONTEXT, Guid_Win32_::CryptAcquireContext, Guid_Win32_::CryptGenRandom, Guid_Win32_::CryptReleaseContext, Guid_Win32_::FORMAT_MESSAGE_FROM_SYSTEM, Guid_Win32_::FORMAT_MESSAGE_IGNORE_INSERTS, Guid_Win32_::FormatMessageA, Guid_Win32_::GetLastError, Guid_Win32_::PROV_RSA_FULL
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Guid_Unix_
#initialize
#initialize, #lastErrorMessage
Class Method Details
.from_raw(bytes) ⇒ Object
108
109
110
111
112
113
114
|
# File 'lib/wwmd/guid.rb', line 108
def self.from_raw(bytes)
raise ArgumentError, "Invalid GUID raw bytes, length must be 16 bytes" unless
bytes.length == 16
guid = Guid.allocate
guid.instance_eval { @bytes = bytes }
guid
end
|
.from_s(s) ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/wwmd/guid.rb', line 100
def self.from_s(s)
raise ArgumentError, "Invalid GUID hexstring" unless
s =~ /\A[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}\z/i
guid = Guid.allocate
guid.instance_eval { @bytes = [s.gsub(/[^0-9a-f]+/i, '')].pack "h*" }
guid
end
|
Instance Method Details
#==(other) ⇒ Object
116
117
118
|
# File 'lib/wwmd/guid.rb', line 116
def ==(other)
@bytes == other.raw
end
|
#hexdigest ⇒ Object
84
85
86
|
# File 'lib/wwmd/guid.rb', line 84
def hexdigest
@bytes.unpack("h*")[0]
end
|
#inspect ⇒ Object
92
93
94
|
# File 'lib/wwmd/guid.rb', line 92
def inspect
to_s
end
|
#raw ⇒ Object
96
97
98
|
# File 'lib/wwmd/guid.rb', line 96
def raw
@bytes
end
|
#to_s ⇒ Object
88
89
90
|
# File 'lib/wwmd/guid.rb', line 88
def to_s
@bytes.unpack("h8 h4 h4 h4 h12").join "-"
end
|