Class: ProtocolBuffers::Field::NumericField

Inherits:
ProtocolBuffers::Field show all
Defined in:
lib/protocol_buffers/runtime/field.rb

Instance Attribute Summary

Attributes inherited from ProtocolBuffers::Field

#name, #otype, #tag

Instance Method Summary collapse

Methods inherited from ProtocolBuffers::Field

#add_methods_to, #check_valid, create, #deserialize, #inspect_value, #repeated?, #serialize, #valid_type?

Instance Method Details

#check_value(value) ⇒ Object

Raises:

  • (ArgumentError)


277
278
279
# File 'lib/protocol_buffers/runtime/field.rb', line 277

def check_value(value)
  raise(ArgumentError, "value is out of range for type #{self.class.name}: #{value}") unless value >= min && value <= max
end

#default_valueObject



281
282
283
# File 'lib/protocol_buffers/runtime/field.rb', line 281

def default_value
  @opts[:default] || 0
end

#maxObject



273
274
275
# File 'lib/protocol_buffers/runtime/field.rb', line 273

def max
  1.0 / 0.0
end

#minObject



269
270
271
# File 'lib/protocol_buffers/runtime/field.rb', line 269

def min
  0
end