Class: Integer
- Inherits:
-
Object
- Object
- Integer
- Defined in:
- lib/casual_support/integer/to_hex.rb
Instance Method Summary collapse
-
#to_hex(width = 0) ⇒ String
Formats the Integer as a zero-padded lower-case hexadecimal string.
Instance Method Details
#to_hex(width = 0) ⇒ String
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).
15 16 17 |
# File 'lib/casual_support/integer/to_hex.rb', line 15 def to_hex(width = 0) width > 1 ? self.to_s(16).rjust(width, '0'.freeze) : self.to_s(16) end |