Class: Protobuf::Field::FloatField
- Defined in:
- lib/protobuf/field/float_field.rb
Direct Known Subclasses
Constant Summary
Constants inherited from BaseField
Instance Attribute Summary
Attributes inherited from BaseField
#default, #default_value, #deprecated, #extension, #getter_method_name, #message_class, #name, #optional, #packed, #repeated, #required, #rule, #setter_method_name, #tag, #type_class
Class Method Summary collapse
-
.default ⇒ Object
Class Methods.
Instance Method Summary collapse
-
#acceptable?(val) ⇒ Boolean
Public Instance Methods.
- #decode(bytes) ⇒ Object
- #encode(value) ⇒ Object
- #wire_type ⇒ Object
Methods inherited from BaseField
#deprecated?, #enum?, #extension?, #initialize, #message?, #optional?, #packed?, #repeated?, #repeated_message?, #required?, #set, #to_s, #type, #warn_if_deprecated
Constructor Details
This class inherits a constructor from Protobuf::Field::BaseField
Class Method Details
.default ⇒ Object
Class Methods
11 12 13 |
# File 'lib/protobuf/field/float_field.rb', line 11 def self.default 0.0 end |
Instance Method Details
#acceptable?(val) ⇒ Boolean
Public Instance Methods
19 20 21 |
# File 'lib/protobuf/field/float_field.rb', line 19 def acceptable?(val) val.respond_to?(:to_f) end |
#decode(bytes) ⇒ Object
23 24 25 |
# File 'lib/protobuf/field/float_field.rb', line 23 def decode(bytes) bytes.unpack('e').first end |
#encode(value) ⇒ Object
27 28 29 |
# File 'lib/protobuf/field/float_field.rb', line 27 def encode(value) [value].pack('e') end |