Sha256: 23c2d3cbf5d50a048fa6f4bf0d8c90f0eb3b743636138bd17da90ab77cd7e339

Contents?: true

Size: 540 Bytes

Versions: 18

Compression:

Stored size: 540 Bytes

Contents

module MinMaxComparison
  # Returns the greater of the object's value or +value+
  def max( value )
    if value > self
      value
    else
      self
    end
  end
  
  # Returns the lesser of the object's value or +value+
  def min( value )
    if value < self
      value
    else
      self
    end
  end
end

class Fixnum
  include MinMaxComparison
end

class Rational
  include MinMaxComparison
end

class Float
  include MinMaxComparison

  def precision(pre)
    mult = 10 ** pre
    (self * mult).truncate.to_f / mult
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
wdd-ruby-ext-0.6.3 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.6.2 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.6.0 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.5.1 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.5.0 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.4.4 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.4.3 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.4.2 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.4.1 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.4.0 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.3.3 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.3.2 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.3.1 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.3.0 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.2.3 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.2.2 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.2.1 lib/wdd-ruby-ext/numbers.rb
wdd-ruby-ext-0.2.0 lib/wdd-ruby-ext/numbers.rb