| Class | Uttk::Weights::WExpr |
| In: |
lib/uttk/weights/WExpr.rb
|
| Parent: | Weight |
| expr | [RW] |
# File lib/uttk/weights/WExpr.rb, line 15 def initialize ( aFloat, min=0, max=1, expr=nil ) super(aFloat, min, max) @expr = expr || "#{to_f}[#@min, #@max]" end
# File lib/uttk/weights/WExpr.rb, line 26 def * ( rhs ) x = super x.expr = "(#{to_s} * #{rhs.to_s})[#{x.min}, #{x.max}]" x end
# File lib/uttk/weights/WExpr.rb, line 20 def + ( rhs ) x = super x.expr = "(#{@expr} + #{rhs.to_s})[#{x.min}, #{x.max}]" x end
# File lib/uttk/weights/WExpr.rb, line 48 def get @expr + " == #{to_f.to_s} == #{(to_f * 100).floor}%" end
# File lib/uttk/weights/WExpr.rb, line 33 def normalize ( weight ) diff = @max - @min if diff.zero? if @max.zero? and weight.zero? self.class.new(:PASS) else self.class.new(:FAIL) end else self.class.new((self - @min) / diff, 0, 1, "((#{to_s} - #{min.to_s}) / (#{max.to_s} - #{min.to_s}))") end end