Sha256: d0b229faf2a4cc8ec3dd2f7fb0ad1f97665f9d919b1e7a2520dd077fa620ff6b
Contents?: true
Size: 531 Bytes
Versions: 1
Compression:
Stored size: 531 Bytes
Contents
# frozen_string_literal: true class Integer # Formats the Integer as a zero-padded lower-case hexadecimal string. # If the length of the raw hexadecimal string exceeds the desired # width, the string will be returned as-is (without padding or # truncation). # # @example # 250.to_hex # == "fa" # 250.to_hex(4) # == "00fa" # 250.to_hex(1) # == "fa" # # @param width [Integer] # @return [String] def to_hex(width = 0) width > 1 ? self.to_s(16).rjust(width, "0") : self.to_s(16) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
casual_support-3.0.2 | lib/casual_support/integer/to_hex.rb |