Class: Integer

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

Instance Method Summary collapse

Instance Method Details

#itbObject



198
199
200
# File 'lib/tapyrus.rb', line 198

def itb
  to_even_length_hex.htb
end

#to_bits(length = nil) ⇒ Object

convert bit string



203
204
205
206
207
208
209
# File 'lib/tapyrus.rb', line 203

def to_bits(length = nil )
  if length
    to_s(2).rjust(length, '0')
  else
    to_s(2)
  end
end

#to_even_length_hexObject



193
194
195
196
# File 'lib/tapyrus.rb', line 193

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