class RubySMB::Dcerpc::Uuid
[Universal Unique Identifier](pubs.opengroup.org/onlinepubs/9629399/apdxa.htm)
Public Instance Methods
get()
click to toggle source
# File lib/ruby_smb/dcerpc/uuid.rb, line 15 def get "#{to_string_le(time_low.to_binary_s)}"\ "-#{to_string_le(time_mid.to_binary_s)}"\ "-#{to_string_le(time_hi_and_version.to_binary_s)}"\ "-#{clock_seq_hi_and_reserved.to_hex}#{clock_seq_low.to_hex}"\ "-#{node.to_hex}" end
set(uuid_string)
click to toggle source
# File lib/ruby_smb/dcerpc/uuid.rb, line 23 def set(uuid_string) components = uuid_string.split('-') self.time_low.read(to_binary_le(components[0])) self.time_mid.read(to_binary_le(components[1])) self.time_hi_and_version.read(to_binary_le(components[2])) self.clock_seq_hi_and_reserved.read(components[3][0,2].hex.chr) self.clock_seq_low.read(components[3][2,2].hex.chr) self.node.read(components[4].gsub(/../) {|e| e.hex.chr}) end
Private Instance Methods
to_binary_le(str)
click to toggle source
# File lib/ruby_smb/dcerpc/uuid.rb, line 36 def to_binary_le(str) str.scan(/../).map {|char| char.hex.chr}.reverse.join end
to_string_le(bin)
click to toggle source
# File lib/ruby_smb/dcerpc/uuid.rb, line 40 def to_string_le(bin) bin.each_byte.map {|byte| byte.to_s(16).rjust(2, '0')}.reverse.join end