Class: Integer

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

Instance Method Summary collapse

Instance Method Details

#itbObject



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

def itb
  to_even_length_hex.htb
end

#to_bits(length = nil) ⇒ Object

convert bit string



175
176
177
# File 'lib/tapyrus.rb', line 175

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

#to_even_length_hexObject



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

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