Sha256: 8a3911930d2ccbfe2016f2d2ebb674cf5458a1abaa1206616b5c97e68d290d2e

Contents?: true

Size: 563 Bytes

Versions: 28

Compression:

Stored size: 563 Bytes

Contents

require 'protobuf/field/base_field'

module Protobuf
  module Field
    class FloatField < BaseField

      ##
      # Class Methods
      #

      def self.default
        0.0
      end

      ##
      # Public Instance Methods
      #

      def acceptable?(val)
        val.respond_to?(:to_f)
      end

      def coerce!(val)
        Float(val)
      end

      def decode(bytes)
        bytes.unpack('e').first
      end

      def encode(value)
        [value].pack('e')
      end

      def wire_type
        WireType::FIXED32
      end

    end
  end
end

Version data entries

28 entries across 28 versions & 4 rubygems

Version Path
protobuf-core-3.5.0 lib/protobuf/field/float_field.rb
protobuffy-4.0.1 lib/protobuf/field/float_field.rb
protobuffy-4.0.0 lib/protobuf/field/float_field.rb
protobuf-3.6.12 lib/protobuf/field/float_field.rb
protobuf-3.6.11 lib/protobuf/field/float_field.rb
protobuf-3.6.10 lib/protobuf/field/float_field.rb
protobuf-3.7.0.pre2 lib/protobuf/field/float_field.rb
protobuf-3.6.9 lib/protobuf/field/float_field.rb
protobuf-3.7.0.pre1 lib/protobuf/field/float_field.rb
protobuf-3.7.0.pre0 lib/protobuf/field/float_field.rb
protobuf-3.6.7 lib/protobuf/field/float_field.rb
protobuf-3.6.6 lib/protobuf/field/float_field.rb
protobuf-3.6.2 lib/protobuf/field/float_field.rb
protobuf-3.6.1 lib/protobuf/field/float_field.rb
protobuf-3.6.0 lib/protobuf/field/float_field.rb
protobuf-3.5.5 lib/protobuf/field/float_field.rb
protobuf-3.5.4 lib/protobuf/field/float_field.rb
protobuf-3.5.3 lib/protobuf/field/float_field.rb
protobuf-3.5.2 lib/protobuf/field/float_field.rb
protobuf-3.5.1 lib/protobuf/field/float_field.rb