module Scale::Types::FixedWidthUInt
Public Class Methods
included(base)
click to toggle source
# File lib/scale/base.rb, line 144 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
encode()
click to toggle source
# File lib/scale/base.rb, line 148 def encode if value.class != ::Integer raise "#{self.class}'s value must be integer" end byte_length = self.class::BYTE_LENGTH bytes = value.to_s(16).rjust(byte_length * 2, "0").scan(/.{2}/).reverse.map {|hex| hex.to_i(16) } bytes.bytes_to_hex[2..] end