Sha256: f58c1eb5e97752cc2507caec37afcba53c053c0ac6f7370b48da994be4fa15a3
Contents?: true
Size: 698 Bytes
Versions: 7
Compression:
Stored size: 698 Bytes
Contents
module Vedeu # Forces the value within defined limits. # class Limit # @see #new, #apply def self.apply(v, vn, max, min = 1) new(v, vn, max, min).apply end # @param v [Fixnum] # @param vn [Fixnum] # @param max [Fixnum] # @param min [Fixnum] # @return [Vedeu::Limit] def initialize(v, vn, max, min = 1) @v = v @vn = vn @max = max @min = min || 1 end # @return [Fixnum] def apply if (v + vn) > max applied = vn - ((v + vn) - max) return applied < min ? min : applied else vn end end private attr_reader :v, :vn, :min, :max end # Limit end # Vedeu
Version data entries
7 entries across 7 versions & 1 rubygems