Sha256: 5675df7e810fdfcf959ffce9db755534419eef42423fec1bfaa252d9aa87630b

Contents?: true

Size: 1 KB

Versions: 14

Compression:

Stored size: 1 KB

Contents

class Integer
  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Fixnum.html]
  def even?
    self[0].zero?
  end unless method_defined? :even?

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Fixnum.html]
  def odd?
    !even?
  end unless method_defined? :odd?

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Fixnum.html]
  def ord
    self
  end

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Fixnum.html]
  def succ
    self + 1
  end unless method_defined? :succ

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Fixnum.html]
  def pred
    self - 1
  end unless method_defined? :succ
  
  alias_method :magnitude, :abs unless method_defined? :magnitude
  
  make_block_optional :downto, :times, :upto, :test_on => 42, :arg => 42
end

class Numeric
  make_block_optional :step, :test_on => 42, :arg => [100, 6]
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
marcandre-backports-1.6.0 lib/backports/integer.rb
marcandre-backports-1.6.1 lib/backports/integer.rb
marcandre-backports-1.6.3 lib/backports/integer.rb
marcandre-backports-1.6.4 lib/backports/integer.rb
marcandre-backports-1.6.6 lib/backports/integer.rb
marcandre-backports-1.6.7 lib/backports/integer.rb
marcandre-backports-1.6.8 lib/backports/integer.rb
backports-1.6.1 lib/backports/integer.rb
backports-1.6.6 lib/backports/integer.rb
backports-1.6.3 lib/backports/integer.rb
backports-1.6.4 lib/backports/integer.rb
backports-1.6.8 lib/backports/integer.rb
backports-1.6.0 lib/backports/integer.rb
backports-1.6.7 lib/backports/integer.rb