Class: Protobuf::Field::FloatField
Instance Attribute Summary
Attributes inherited from BaseField
#default, #default_value, #message_class, #name, #rule, #tag, #type
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseField
descriptor, #descriptor, #initialize, #initialized?, #max, #merge, #min, #optional?, #packed?, #ready?, #repeated?, #required?, #set, #to_s
Class Method Details
.default ⇒ Object
476
|
# File 'lib/protobuf/message/field.rb', line 476
def self.default; 0.0; end
|
.max ⇒ Object
477
|
# File 'lib/protobuf/message/field.rb', line 477
def self.max; 1.0/0; end
|
.min ⇒ Object
478
|
# File 'lib/protobuf/message/field.rb', line 478
def self.min; -1.0/0; end
|
Instance Method Details
#acceptable?(val) ⇒ Boolean
492
493
494
495
496
|
# File 'lib/protobuf/message/field.rb', line 492
def acceptable?(val)
raise TypeError, val.class.name unless val.is_a?(Numeric)
raise RangeError if val < min || max < val
true
end
|
#decode(bytes) ⇒ Object
484
485
486
|
# File 'lib/protobuf/message/field.rb', line 484
def decode(bytes)
bytes.unpack('e').first
end
|
#encode(value) ⇒ Object
488
489
490
|
# File 'lib/protobuf/message/field.rb', line 488
def encode(value)
[value].pack('e')
end
|
#wire_type ⇒ Object
480
481
482
|
# File 'lib/protobuf/message/field.rb', line 480
def wire_type
WireType::FIXED32
end
|