Class: NoSE::Fields::FloatField

Inherits:
Field show all
Defined in:
lib/nose/model/fields.rb

Overview

Field holding a float

Constant Summary collapse

TYPE =

Any Fixnum is a valid float

Fixnum

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) ⇒ FloatField

Returns a new instance of FloatField.



173
174
175
# File 'lib/nose/model/fields.rb', line 173

def initialize(name, **options)
  super(name, 8, **options)
end

Class Method Details

.value_from_string(string) ⇒ Object

Parse a Float from the provided parameter



178
179
180
# File 'lib/nose/model/fields.rb', line 178

def self.value_from_string(string)
  string.to_f
end

Instance Method Details

#random_valueObject

Random numbers up to the given size



183
184
185
# File 'lib/nose/model/fields.rb', line 183

def random_value
  rand(@cardinality).to_f
end