Class: NoSE::Fields::IntegerField

Inherits:
Field show all
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

Instance Method Summary collapse

Methods inherited from Field

#*, #==, #cardinality, #hash, #id, #to_color, #to_s

Methods included from Supertype

included

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, **options)
  super(name, 8, **options)
  @cardinality = 10
end

Class Method Details

.value_from_string(string) ⇒ Fixnum

Parse an Integer from the provided parameter

Returns:

  • (Fixnum)


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_valueFixnum

Random numbers up to the given size

Returns:

  • (Fixnum)


132
133
134
# File 'lib/nose/model/fields.rb', line 132

def random_value
  rand(@cardinality)
end