Class: Etheruby::Encoders::Ufixed

Inherits:
FixedBase show all
Defined in:
lib/etheruby/encoders/fixed.rb

Instance Attribute Summary

Attributes inherited from FixedBase

#size_d, #size_i

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from FixedBase

#initialize

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Etheruby::Encoders::FixedBase

Instance Method Details

#decodeObject



70
71
72
73
74
# File 'lib/etheruby/encoders/fixed.rb', line 70

def decode
  @data = data[0..63]
  return Uint.new(data[0..(size_i/4)-1]).decode[0] +
    decode_decimal_representation(data[(size_i / 4)..data.length]), 32
end

#encodeObject



65
66
67
68
# File 'lib/etheruby/encoders/fixed.rb', line 65

def encode
  raise InvalidFormatForDataError.new("Unsigned fixed #{data} < 0") if data < 0
  Fixed.new(size_i, size_d, data).encode
end