Class: Integer

Inherits:
Object
  • Object
show all
Defined in:
lib/unisec/utils.rb

Instance Method Summary collapse

Instance Method Details

#to_binString

Convert an integer to an binary string

Examples:

42.to_bin # => "101010"

Returns:

  • (String)

    The interger converted to binary and casted to a string



18
19
20
# File 'lib/unisec/utils.rb', line 18

def to_bin
  to_s(2)
end

#to_hexString

Convert an integer to an hexadecimal string

Examples:

42.to_hex # => "2A"

Returns:

  • (String)

    The interger converted to hexadecimal and casted to an upper case string



10
11
12
# File 'lib/unisec/utils.rb', line 10

def to_hex
  to_s(16).upcase
end