Sha256: 8798820416858569d12841bf7e4429ad60e04812d7359306cfeb8736917c4e20

Contents?: true

Size: 564 Bytes

Versions: 11

Compression:

Stored size: 564 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

11 entries across 11 versions & 1 rubygems

Version Path
protobuf-3.3.6 lib/protobuf/field/float_field.rb
protobuf-3.3.5 lib/protobuf/field/float_field.rb
protobuf-3.3.4 lib/protobuf/field/float_field.rb
protobuf-3.3.3 lib/protobuf/field/float_field.rb
protobuf-3.3.2 lib/protobuf/field/float_field.rb
protobuf-3.3.1 lib/protobuf/field/float_field.rb
protobuf-3.3.0 lib/protobuf/field/float_field.rb
protobuf-3.2.1 lib/protobuf/field/float_field.rb
protobuf-3.2.0 lib/protobuf/field/float_field.rb
protobuf-3.1.0 lib/protobuf/field/float_field.rb
protobuf-3.0.5 lib/protobuf/field/float_field.rb