Class: NudgeType::BoolType

Inherits:
Object
  • Object
show all
Extended by:
TypeBehaviors
Defined in:
lib/interpreter/types/pushTypes.rb

Class Method Summary collapse

Methods included from TypeBehaviors

any_value, extended, from_s, random_value, recognizes?, to_nudgecode

Class Method Details

.any_value(options = {}) ⇒ Object



94
95
96
# File 'lib/interpreter/types/pushTypes.rb', line 94

def self.any_value(options ={})
  self.random_value(options)
end

.from_s(string_value) ⇒ Object



86
87
88
# File 'lib/interpreter/types/pushTypes.rb', line 86

def self.from_s(string_value)
  string_value.downcase == "true" ? true : false
end

.random_value(params = {}) ⇒ Object



81
82
83
84
# File 'lib/interpreter/types/pushTypes.rb', line 81

def self.random_value(params = {})
  p = params[:randomBooleanTruthProb] || 0.5
  rand() < p
end

.recognizes?(a_thing) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/interpreter/types/pushTypes.rb', line 90

def self.recognizes?(a_thing)
  a_thing.kind_of?(TrueClass) || a_thing.kind_of?(FalseClass)
end