module RLP::Extensions::Array
Public Instance Methods
as_int()
click to toggle source
# File lib/core_ext/array.rb, line 12 def as_int self.reverse_bytes end
as_string()
click to toggle source
# File lib/core_ext/array.rb, line 8 def as_string self.collect{|x| x.as_string}.join end
get(position)
click to toggle source
# File lib/core_ext/array.rb, line 4 def get(position) self[position] end
reverse_bytes()
click to toggle source
# File lib/core_ext/array.rb, line 32 def reverse_bytes bytes = self.collect do |item| item.chr end (8 - bytes.length).times do bytes.insert(0, 0.chr) end bytes.join.unpack("q>").first end
to_rlp()
click to toggle source
# File lib/core_ext/array.rb, line 16 def to_rlp return [0xc0] if self == [] result = self.collect do |item| rlp = item.to_rlp if rlp.is_a?(Array) rlp.to_a.collect{|x| x.chr} else rlp.chr end end.flatten result = result.join.to_rlp(true) return result end