
class Numeric

  # Allows #succ to take _n_ increments.
  #
  #   3.succ(2)  #=> 5
  #
  def succ(n=nil)
    n ||= 1
    self + n
  end

  # Provides #pred as the opposite of #succ.
  #
  #   3.pred(2)  #=> 1
  #
  def pred(n=nil)
    n ||= 1
    self - n
  end

end


class Integer

  # This is needed to allow Integer to look back to
  # its Numeric ancestor for the new definition of #succ.
  #if instance_methods(false).include?( :succ )
    remove_method( :succ )
  #end

end



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCNumeric < Test::Unit::TestCase

    def test_pred
      assert_equal(  3,  4.pred )
      assert_equal( -3, -2.pred )
      assert_equal(  2,  4.pred(2) )
      assert_equal( -4, -2.pred(2) )
      assert_equal(  6,  4.pred(-2) )
      assert_equal(  0, -2.pred(-2) )
    end

    def test_succ
      assert_equal(  5,  4.succ )
      assert_equal( -1, -2.succ )
      assert_equal(  6,  4.succ(2) )
      assert_equal(  0, -2.succ(2) )
      assert_equal(  2,  4.succ(-2) )
      assert_equal( -4, -2.succ(-2) )
    end

  end

=end
