Class: NoSE::Fields::StringField

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

Overview

Field holding a string of some average length

Constant Summary collapse

TYPE =

Strings are stored as strings

String

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, length = 10, **options) ⇒ StringField

Returns a new instance of StringField.



204
205
206
# File 'lib/nose/model/fields.rb', line 204

def initialize(name, length = 10, **options)
  super(name, length, **options)
end

Class Method Details

.value_from_string(string) ⇒ String

Return the String parameter as-is

Returns:

  • (String)


210
211
212
# File 'lib/nose/model/fields.rb', line 210

def self.value_from_string(string)
  string
end

Instance Method Details

#random_valueString

A random string of the correct length

Returns:

  • (String)


216
217
218
# File 'lib/nose/model/fields.rb', line 216

def random_value
  Faker::Lorem.characters(number: @size)
end