Class: NoSE::Fields::FloatField

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

Overview

Field holding a float

Constant Summary collapse

TYPE =
Float

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.



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

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

Class Method Details

.value_from_string(string) ⇒ Object

Parse a Float from the provided parameter



189
190
191
# File 'lib/nose/model/fields.rb', line 189

def self.value_from_string(string)
  string.to_f
end

Instance Method Details

#random_valueObject

Random numbers up to the given size



194
195
196
# File 'lib/nose/model/fields.rb', line 194

def random_value
  rand(@cardinality).to_f
end