class NoSE::Fields::BooleanField
Field
holding a boolean value
Constants
- TYPE
Since Ruby has no boolean type, we use
Object
but all values will be either false or true
Public Class Methods
new(name, **options)
click to toggle source
Calls superclass method
NoSE::Fields::Field::new
# File lib/nose/model/fields.rb, line 155 def initialize(name, **options) super(name, 1, **options) @cardinality = 2 end
value_from_string(string)
click to toggle source
Check for strings true or false otherwise assume integer @return [Boolean]
# File lib/nose/model/fields.rb, line 162 def self.value_from_string(string) string = string.downcase if string[0] == 't' return true elsif string[0] == 'f' return false else [false, true][string.to_i] end end
Public Instance Methods
random_value()
click to toggle source
Randomly true or false @return [Boolean]
# File lib/nose/model/fields.rb, line 175 def random_value [false, true][rand(2)] end