aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/integer.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/integer/inquiry.rb19
2 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/integer.rb b/activesupport/lib/active_support/core_ext/integer.rb
index a44a1b4c74..f5b185b42b 100644
--- a/activesupport/lib/active_support/core_ext/integer.rb
+++ b/activesupport/lib/active_support/core_ext/integer.rb
@@ -1,3 +1,4 @@
require 'active_support/core_ext/integer/multiple'
require 'active_support/core_ext/integer/inflections'
+require 'active_support/core_ext/integer/inquiry'
require 'active_support/core_ext/integer/time'
diff --git a/activesupport/lib/active_support/core_ext/integer/inquiry.rb b/activesupport/lib/active_support/core_ext/integer/inquiry.rb
new file mode 100644
index 0000000000..dc710b74d0
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/integer/inquiry.rb
@@ -0,0 +1,19 @@
+class Integer
+ # Returns true if the number is positive.
+ #
+ # 1.positive? # => true
+ # 0.positive? # => false
+ # -1.positive? # => false
+ def positive?
+ self > 0
+ end
+
+ # Returns true if the number is positive.
+ #
+ # -1.positive? # => true
+ # 0.positive? # => false
+ # 1.positive? # => false
+ def negative?
+ self < 0
+ end
+end