Sha256: 97b313fb1d545a677bfe3e280aa41dcf658682fd9726d35dc348cac321bb1b0e

Contents?: true

Size: 584 Bytes

Versions: 20

Compression:

Stored size: 584 Bytes

Contents

module Etherlite::Types
  class Boolean < Base
    TRUE = '0000000000000000000000000000000000000000000000000000000000000001'.freeze # 32 bytes
    FALSE = '0000000000000000000000000000000000000000000000000000000000000000'.freeze

    def signature
      "bool"
    end

    def size
      32
    end

    def encode(_value)
      unless _value.is_a?(TrueClass) || _value.is_a?(FalseClass)
        raise ArgumentError, "value must be a boolean for #{signature}"
      end

      _value ? TRUE : FALSE
    end

    def decode(_connection, _value)
      _value.hex > 0
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
etherlite-0.6.0 lib/etherlite/types/boolean.rb
etherlite-0.5.3 lib/etherlite/types/boolean.rb
etherlite-0.5.2 lib/etherlite/types/boolean.rb
etherlite-0.5.1 lib/etherlite/types/boolean.rb
etherlite-0.5.0 lib/etherlite/types/boolean.rb
etherlite-0.4.2 lib/etherlite/types/boolean.rb
etherlite-0.4.1 lib/etherlite/types/boolean.rb
etherlite-0.4.0 lib/etherlite/types/boolean.rb
etherlite-0.3.0 lib/etherlite/types/boolean.rb
etherlite-0.2.6 lib/etherlite/types/boolean.rb
etherlite-0.2.5 lib/etherlite/types/boolean.rb
etherlite-0.2.4 lib/etherlite/types/boolean.rb
etherlite-0.2.3 lib/etherlite/types/boolean.rb
etherlite-0.2.2 lib/etherlite/types/boolean.rb
etherlite-0.2.1 lib/etherlite/types/boolean.rb
etherlite-0.2.0 lib/etherlite/types/boolean.rb
etherlite-0.1.8 lib/etherlite/types/boolean.rb
etherlite-0.1.7 lib/etherlite/types/boolean.rb
etherlite-0.1.6 lib/etherlite/types/boolean.rb
etherlite-0.1.5 lib/etherlite/types/boolean.rb