Class: Integer
- Inherits:
-
Object
- Object
- Integer
- Defined in:
- lib/bases/monkeypatches/integer.rb
Overview
Some monkeypatches to the Integer class.
Instance Method Summary collapse
-
#to_base(base, opts = {}) ⇒ String
Convert this number to a given
base. -
#to_binary ⇒ String
Convert this number in binary form.
-
#to_hex ⇒ String
Convert this number in hexadecimal form.
Instance Method Details
#to_base(base, opts = {}) ⇒ String
Convert this number to a given base.
9 10 11 |
# File 'lib/bases/monkeypatches/integer.rb', line 9 def to_base(base, opts = {}) Bases.val(self).to_base(base, opts) end |
#to_binary ⇒ String
Convert this number in binary form.
16 17 18 |
# File 'lib/bases/monkeypatches/integer.rb', line 16 def to_binary to_base(2) end |
#to_hex ⇒ String
Convert this number in hexadecimal form.
23 24 25 |
# File 'lib/bases/monkeypatches/integer.rb', line 23 def to_hex to_base(16) end |