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
#message_class, #name, #options, #rule, #tag, #type_class
Class Method Summary collapse
-
.default ⇒ Object
Class Methods.
Instance Method Summary collapse
-
#acceptable?(val) ⇒ Boolean
Public Instance Methods.
- #coerce!(val) ⇒ Object
- #decode(bytes) ⇒ Object
- #encode(value) ⇒ Object
- #wire_type ⇒ Object
Methods inherited from BaseField
#default, #default_value, #deprecated?, #enum?, #extension?, #getter, #initialize, #message?, #optional?, #packed?, #repeated?, #repeated_message?, #required?, #set, #setter, #to_s, #type, #warn_if_deprecated
Methods included from Logging
initialize_logger, #log_exception, #log_signature, #logger, logger, logger=, #sign_message
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 |
#coerce!(val) ⇒ Object
23 24 25 |
# File 'lib/protobuf/field/float_field.rb', line 23 def coerce!(val) Float(val) end |
#decode(bytes) ⇒ Object
27 28 29 |
# File 'lib/protobuf/field/float_field.rb', line 27 def decode(bytes) bytes.unpack('e').first end |
#encode(value) ⇒ Object
31 32 33 |
# File 'lib/protobuf/field/float_field.rb', line 31 def encode(value) [value].pack('e') end |