Class: Integer

Inherits:
Object show all
Defined in:
lib/backports/1.9/integer.rb,
lib/backports/1.8.7/integer.rb

Instance Method Summary collapse

Instance Method Details

#even?Boolean

Standard in ruby 1.8.7+. See official documentation

Returns:

  • (Boolean)


5
6
7
# File 'lib/backports/1.8.7/integer.rb', line 5

def even?
  self[0].zero?
end

#odd?Boolean

Standard in ruby 1.8.7+. See official documentation

Returns:

  • (Boolean)


10
11
12
# File 'lib/backports/1.8.7/integer.rb', line 10

def odd?
  !even?
end

#ordObject

Standard in ruby 1.8.7+. See official documentation



15
16
17
# File 'lib/backports/1.8.7/integer.rb', line 15

def ord
  self
end

#predObject

Standard in ruby 1.8.7+. See official documentation



20
21
22
# File 'lib/backports/1.8.7/integer.rb', line 20

def pred
  self - 1
end