lib/uuid/ncname.rb in uuid-ncname-0.4.0 vs lib/uuid/ncname.rb in uuid-ncname-0.4.1
- old
+ new
@@ -210,11 +210,11 @@
# @param radix [32, 64] either the number 32 or the number 64.
#
# @param version [0, 1] An optional formatting version, where 0 is
# the naïve original version and 1 moves the `variant` nybble out
# to the end of the identifier. The default version is 1.
- #
+ #
# @param align [true, false] Optional directive to treat the
# terminating character as aligned to the numerical base of the
# representation. Since the version nybble is removed from the
# string and the first 120 bits divide evenly into both Base32 and
# Base64, the overhang is only ever 4 bits. This means that when
@@ -222,11 +222,11 @@
# range of the letters A through P in (the RFC 3548/4648
# representations of) both Base32 and Base64. When `version` is 1
# and the terminating character is aligned, RFC4122-compliant UUIDs
# will always terminate with `I`, `J`, `K`, or `L`. Defaults to
# `true`.
- #
+ #
# @return [String] The NCName-formatted UUID.
#
def self.to_ncname uuid, radix: 64, version: nil, align: true
raise 'Radix must be either 32, 58, or 64' unless
[32, 58, 64].include? radix
@@ -242,11 +242,11 @@
bin = nil
if uuid.length == 16
bin = uuid
else
- uuid.gsub!(/\s+/, '')
+ uuid = uuid.gsub(/\s+/, '')
if (m = /^(?:urn:uuid:)?([0-9A-Fa-f-]{32,})$/.match(uuid))
bin = [m[1].tr('-', '')].pack 'H*'
elsif (m = /^([0-9A-Za-z+\/_-]+=*)$/.match(uuid))
match = m[1].tr('-_', '+/')
bin = ::Base64.decode64(match)
@@ -267,19 +267,19 @@
# representation. Will return nil if the input doesn't match the
# radix (if supplied) or is otherwise malformed.
#
# @param ncname [#to_s] an NCName-encoded UUID, either a
# 22-character (Base64) variant, or a 26-character (Base32) variant.
- #
+ #
# @param radix [nil, 32, 58, 64] Optional radix; will use a heuristic
# if omitted.
#
# @param format [:str, :urn, :hex, :b64, :bin] An optional formatting
# parameter; defaults to `:str`, the canonical string representation.
#
# @param version [0, 1] See ::to_ncname. Defaults to 1.
- #
+ #
# @param align [nil, true, false] See ::to_ncname for details.
# Setting this parameter to `nil`, the default, will cause the
# decoder to detect the alignment state from the identifier.
#
# @param validate [false, true] Check that the ninth (the variant)
@@ -333,13 +333,13 @@
end
# Shorthand for conversion to the Base64 version
#
# @param uuid [#to_s] The UUID
- #
+ #
# @param version [0, 1] See ::to_ncname.
- #
+ #
# @param align [true, false] See ::to_ncname.
#
# @return [String] The Base64-encoded NCName
#
def self.to_ncname_64 uuid, version: nil, align: true
@@ -349,13 +349,13 @@
# Shorthand for conversion from the Base64 version
#
# @param ncname [#to_s] The Base64 variant of the NCName-encoded UUID
#
# @param format [:str, :hex, :b64, :bin] The format
- #
+ #
# @param version [0, 1] See ::to_ncname.
- #
+ #
# @param align [true, false] See ::to_ncname.
#
# @return [String, nil] The corresponding UUID or nil if the input
# is malformed.
#
@@ -365,13 +365,13 @@
end
# Shorthand for conversion to the Base58 version
#
# @param uuid [#to_s] The UUID
- #
+ #
# @param version [0, 1] See ::to_ncname.
- #
+ #
# @param align [true, false] See ::to_ncname.
#
# @return [String] The Base58-encoded NCName
#
def self.to_ncname_58 uuid, version: nil, align: true
@@ -381,13 +381,13 @@
# Shorthand for conversion from the Base58 version
#
# @param ncname [#to_s] The Base58 variant of the NCName-encoded UUID
#
# @param format [:str, :hex, :b64, :bin] The format
- #
+ #
# @param version [0, 1] See ::to_ncname.
- #
+ #
# @param align [true, false] See ::to_ncname.
#
# @return [String, nil] The corresponding UUID or nil if the input
# is malformed.
#
@@ -397,13 +397,13 @@
end
# Shorthand for conversion to the Base32 version
#
# @param uuid [#to_s] The UUID
- #
+ #
# @param version [0, 1] See ::to_ncname.
- #
+ #
# @param align [true, false] See ::to_ncname.
#
# @return [String] The Base32-encoded NCName
#
def self.to_ncname_32 uuid, version: nil, align: true
@@ -413,13 +413,13 @@
# Shorthand for conversion from the Base32 version
#
# @param ncname [#to_s] The Base32 variant of the NCName-encoded UUID
#
# @param format [:str, :hex, :b64, :bin] The format
- #
+ #
# @param version [0, 1] See ::to_ncname.
- #
+ #
# @param align [true, false] See ::to_ncname.
#
# @return [String, nil] The corresponding UUID or nil if the input
# is malformed.
#
@@ -449,10 +449,10 @@
token = token.to_s
if MATCH.match? token
# false is definitely version zero but true is only maybe version 1
version = /^(?:.{21}[I-L]|.{25}[I-Li-l])$/.match(token) ? 1 : 0
- # try decoding with validation on
+ # try decoding with validation on
uu = from_ncname token, version: version, validate: true
# note that version 1 will always return something because the
# method of detecting it is a version 1 also happens to be the
# method of determining whether or not it is valid.