Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/jkrall/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoldstein committed Aug 11, 2015
2 parents cbf7fe7 + 3cd907b commit ece10ce
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/uuidtools.rb
Expand Up @@ -164,7 +164,7 @@ def self.parse(uuid_string)
clock_seq_hi_and_reserved = uuid_components[3].to_i(16)
clock_seq_low = uuid_components[4].to_i(16)
nodes = []
for i in 0..5
6.times do |i|
nodes << uuid_components[5][(i * 2)..(i * 2) + 1].to_i(16)
end
return self.new(time_low, time_mid, time_hi_and_version,
Expand All @@ -186,7 +186,7 @@ def self.parse_raw(raw_string)
clock_seq_hi_and_reserved = (integer >> 56) & 0xFF
clock_seq_low = (integer >> 48) & 0xFF
nodes = []
for i in 0..5
6.times do |i|
nodes << ((integer >> (40 - (i * 8))) & 0xFF)
end
return self.new(time_low, time_mid, time_hi_and_version,
Expand Down Expand Up @@ -249,7 +249,7 @@ def self.timestamp_create(timestamp=nil)
nodes = SecureRandom.random_bytes(6).unpack("C*")
nodes[0] |= 0b00000001
end
for i in 0..5
6.times do |i|
node_id += (nodes[i] << (40 - (i * 8)))
end
clock_sequence = @@last_clock_sequence
Expand Down Expand Up @@ -405,7 +405,7 @@ def <=>(other_uuid)
return check if check != 0
check = self.clock_seq_low <=> other_uuid.clock_seq_low
return check if check != 0
for i in 0..5
6.times do |i|
if (self.nodes[i] < other_uuid.nodes[i])
return -1
end
Expand Down Expand Up @@ -486,7 +486,7 @@ def generate_i
bytes = (time_low << 96) + (time_mid << 80) +
(time_hi_and_version << 64) + (clock_seq_hi_and_reserved << 56) +
(clock_seq_low << 48)
for i in 0..5
6.times do |i|
bytes += (nodes[i] << (40 - (i * 8)))
end
bytes
Expand All @@ -500,7 +500,7 @@ def generate_i
def generate_s
result = sprintf("%8.8x-%4.4x-%4.4x-%2.2x%2.2x-", @time_low, @time_mid,
@time_hi_and_version, @clock_seq_hi_and_reserved, @clock_seq_low);
for i in 0..5
6.times do |i|
result << sprintf("%2.2x", @nodes[i])
end
return result.downcase
Expand Down Expand Up @@ -699,7 +699,7 @@ def self.convert_int_to_byte_string(integer, size)
if byte_string.respond_to?(:force_encoding)
byte_string.force_encoding(Encoding::ASCII_8BIT)
end
for i in 0..(size - 1)
size.times do |i|
byte_string << ((integer >> (((size - 1) - i) * 8)) & 0xFF)
end
return byte_string
Expand All @@ -713,7 +713,7 @@ def self.convert_byte_string_to_int(byte_string)
end
integer = 0
size = byte_string.size
for i in 0..(size - 1)
size.times do |i|
ordinal = (byte_string[i].respond_to?(:ord) ?
byte_string[i].ord : byte_string[i])
integer += (ordinal << (((size - 1) - i) * 8))
Expand Down

0 comments on commit ece10ce

Please sign in to comment.