Class: Integer

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

Instance Method Summary collapse

Instance Method Details

#itbObject



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

def itb
  to_even_length_hex.htb
end

#to_bits(length = nil) ⇒ Object

convert bit string



172
173
174
# File 'lib/tapyrus.rb', line 172

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

#to_even_length_hexObject



162
163
164
165
# File 'lib/tapyrus.rb', line 162

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