| Class | Uttk::Weights::Weight |
| In: |
lib/uttk/weights/Weight.rb
|
| Parent: | Object |
FIXME: document me
| BASE | = | { :START => [0, 0, 0], :PASS => [1, 0, 1], :FAIL => [0, 0, 1] |
| val | -> | get |
| max | [R] | |
| min | [R] | |
| val | [R] |
# File lib/uttk/weights/Weight.rb, line 19 def initialize ( aFloat, min=0, max=1 ) if BASE.has_key? aFloat aFloat, min, max = BASE[aFloat] end aFloat = aFloat.to_f @val = aFloat @min, @max = min, max unless @min <= aFloat or aFloat <= @max raise ArgumentError, "#@min <= #{aFloat} <= #@max" end end
# File lib/uttk/weights/Weight.rb, line 63 def * ( rhs ) f = rhs.to_f a, b, c = to_f * f, @min * f, @max * f b, c = c, b if f < 0 self.class.new(a, b, c) end
# File lib/uttk/weights/Weight.rb, line 58 def + ( rhs ) rhs = self.class.new(rhs) unless rhs.is_a? Weight self.class.new(to_f + rhs.to_f, @min + rhs.min, @max + rhs.max) end
# File lib/uttk/weights/Weight.rb, line 90 def == ( rhs ) rhs.class <= Weight and @min == rhs.min and @val == rhs.val and @max == rhs.max end