Class: Protobuf::Field::FloatField
Instance Attribute Summary
Attributes inherited from BaseField
#default, #message_class, #name, #rule, #tag, #type
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseField
#clear, #default_value, #descriptor, descriptor, #error_message, #get, #initialize, #initialized?, #max, #merge, #merge_array, #merge_value, #min, #optional?, #ready?, #repeated?, #required?, #set, #to_s, #typed_default_value
Class Method Details
.default ⇒ Object
427
|
# File 'lib/protobuf/message/field.rb', line 427
def self.default; 0.0; end
|
.max ⇒ Object
428
|
# File 'lib/protobuf/message/field.rb', line 428
def self.max; 1.0/0; end
|
.min ⇒ Object
429
|
# File 'lib/protobuf/message/field.rb', line 429
def self.min; -1.0/0; end
|
Instance Method Details
#acceptable?(val) ⇒ Boolean
443
444
445
446
447
|
# File 'lib/protobuf/message/field.rb', line 443
def acceptable?(val)
raise TypeError.new(val.class.name) unless val.is_a? Numeric
raise RangeError.new(val) if val < min or max < val
true
end
|
#decode(bytes) ⇒ Object
435
436
437
|
# File 'lib/protobuf/message/field.rb', line 435
def decode(bytes)
bytes.unpack('e').first
end
|
#encode(value) ⇒ Object
439
440
441
|
# File 'lib/protobuf/message/field.rb', line 439
def encode(value)
[value].pack('e')
end
|