Class: NoSE::Fields::IntegerField
- Defined in:
- lib/nose/model/fields.rb
Overview
Field holding an integer
Constant Summary collapse
- TYPE =
Integers are stored as integers
Integer
Instance Attribute Summary
Attributes inherited from Field
#name, #parent, #primary_key, #size
Class Method Summary collapse
-
.value_from_string(string) ⇒ Fixnum
Parse an Integer from the provided parameter.
Instance Method Summary collapse
-
#initialize(name, **options) ⇒ IntegerField
constructor
A new instance of IntegerField.
-
#random_value ⇒ Fixnum
Random numbers up to the given size.
Methods inherited from Field
#*, #==, #cardinality, #hash, #id, #to_color, #to_s
Methods included from Supertype
Constructor Details
#initialize(name, **options) ⇒ IntegerField
Returns a new instance of IntegerField.
119 120 121 122 |
# File 'lib/nose/model/fields.rb', line 119 def initialize(name, **) super(name, 8, **) @cardinality = 10 end |
Class Method Details
.value_from_string(string) ⇒ Fixnum
Parse an Integer from the provided parameter
126 127 128 |
# File 'lib/nose/model/fields.rb', line 126 def self.value_from_string(string) string.to_i end |
Instance Method Details
#random_value ⇒ Fixnum
Random numbers up to the given size
132 133 134 |
# File 'lib/nose/model/fields.rb', line 132 def random_value rand(@cardinality) end |