Class: NudgeType::FloatType
- Inherits:
-
Object
- Object
- NudgeType::FloatType
show all
- Extended by:
- TypeBehaviors
- Defined in:
- lib/interpreter/types/pushTypes.rb
Class Method Summary
collapse
any_value, extended, from_s, random_value, recognizes?, to_nudgecode
Class Method Details
.any_value(options = {}) ⇒ Object
124
125
126
|
# File 'lib/interpreter/types/pushTypes.rb', line 124
def self.any_value(options ={})
self.random_value(options)
end
|
.from_s(string_value) ⇒ Object
116
117
118
|
# File 'lib/interpreter/types/pushTypes.rb', line 116
def self.from_s(string_value)
return string_value.to_f
end
|
.random_value(params = {}) ⇒ Object
108
109
110
111
112
113
114
|
# File 'lib/interpreter/types/pushTypes.rb', line 108
def self.random_value(params = {})
bottom = params[:randomFloatLowerBound] || @defaultLowest
top = params[:randomFloatUpperBound] || @defaultHighest
bottom, top = [bottom,top].min, [bottom,top].max
range = top - bottom
(rand*range) + bottom
end
|
.recognizes?(a_thing) ⇒ Boolean
120
121
122
|
# File 'lib/interpreter/types/pushTypes.rb', line 120
def self.recognizes?(a_thing)
!a_thing.kind_of?(String) && !a_thing.nil? && a_thing.respond_to?(:to_f)
end
|