projects
/
depot.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Functional tests now work properly, bearing in mind whether a user is logged in or...
[depot.git]
/
vendor
/
rails
/
activesupport
/
lib
/
active_support
/
core_ext
/
integer
/
even_odd.rb
1
module
ActiveSupport
#:nodoc:
2
module
CoreExtensions
#:nodoc:
3
module
Integer
#:nodoc:
4
# For checking if a fixnum is even or odd.
5
#
6
# 2.even? # => true
7
# 2.odd? # => false
8
# 1.even? # => false
9
# 1.odd? # => true
10
# 0.even? # => true
11
# 0.odd? # => false
12
# -1.even? # => false
13
# -1.odd? # => true
14
module
EvenOdd
15
def
multiple_of
?(
number
)
16
self
%
number
==
0
17
end
18
19
def
even
?
20
multiple_of
?
2
21
end if
RUBY_VERSION
<
'1.9'
22
23
def
odd
?
24
!
even
?
25
end if
RUBY_VERSION
<
'1.9'
26
end
27
end
28
end
29
end