Class: Integer

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

Instance Method Summary collapse

Instance Method Details

#itbObject



165
166
167
# File 'lib/tapyrus.rb', line 165

def itb
  to_even_length_hex.htb
end

#to_bits(length = nil) ⇒ Object

convert bit string



170
171
172
# File 'lib/tapyrus.rb', line 170

def to_bits(length = nil)
  length ? to_s(2).rjust(length, '0') : to_s(2)
end

#to_even_length_hexObject



160
161
162
163
# File 'lib/tapyrus.rb', line 160

def to_even_length_hex
  hex = to_s(16)
  hex.rjust((hex.length / 2.0).ceil * 2, '0')
end