Sha256: 74179b64b91ea81d6500304334183ae93772d4166f79791b1390a6816c9ac515
Contents?: true
Size: 998 Bytes
Versions: 4
Compression:
Stored size: 998 Bytes
Contents
module Vedeu # Forces the value within defined limits. # class Limit # @param (see #initialize) def self.apply(v, vn, max, min = 1) new(v, vn, max, min).apply end # Returns a new instance of Vedeu::Limit. # # @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 # @!attribute [r] v # @return [Fixnum] attr_reader :v # @!attribute [r] vn # @return [Fixnum] attr_reader :vn # @!attribute [r] min # @return [Fixnum] attr_reader :min # @!attribute [r] max # @return [Fixnum] attr_reader :max end # Limit end # Vedeu
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.4.13 | lib/vedeu/geometry/limit.rb |
vedeu-0.4.12 | lib/vedeu/geometry/limit.rb |
vedeu-0.4.11 | lib/vedeu/geometry/limit.rb |
vedeu-0.4.10 | lib/vedeu/geometry/limit.rb |