Module: RLP::Extensions::Fixnum

Includes:
RLP::Encode
Defined in:
lib/core_ext/fixnum.rb

Instance Method Summary collapse

Methods included from RLP::Encode

#to_rlp

Instance Method Details

#as_intObject



6
7
8
# File 'lib/core_ext/fixnum.rb', line 6

def as_int
  return self
end

#as_stringObject



10
11
12
# File 'lib/core_ext/fixnum.rb', line 10

def as_string
  return self.chr
end

#bytesObject

This makes sure for isntance 1024 becomes [0,0,0,0,0,0,4,0] and in turn [4,0]



19
20
21
# File 'lib/core_ext/fixnum.rb', line 19

def bytes
  [self].pack("q>").bytes.to_a.drop_while{|x| x == 0}
end

#bytesizeObject



14
15
16
# File 'lib/core_ext/fixnum.rb', line 14

def bytesize
  self.bytes.length
end