Module: RLP::Extensions::Fixnum
- Includes:
- RLP::Encode
- Defined in:
- lib/core_ext/fixnum.rb
Instance Method Summary collapse
- #as_int ⇒ Object
- #as_string ⇒ Object
-
#bytes ⇒ Object
This makes sure for isntance 1024 becomes [0,0,0,0,0,0,4,0] and in turn [4,0].
- #bytesize ⇒ Object
Methods included from RLP::Encode
Instance Method Details
#as_int ⇒ Object
6 7 8 |
# File 'lib/core_ext/fixnum.rb', line 6 def as_int return self end |
#as_string ⇒ Object
10 11 12 |
# File 'lib/core_ext/fixnum.rb', line 10 def as_string return self.chr end |
#bytes ⇒ Object
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 |
#bytesize ⇒ Object
14 15 16 |
# File 'lib/core_ext/fixnum.rb', line 14 def bytesize self.bytes.length end |