diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/integer/inquiry.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/integer/inquiry.rb | 19 |
1 files changed, 19 insertions, 0 deletions
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..17a04d4d63 --- /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 negative. + # + # -1.negative? # => true + # 0.negative? # => false + # 1.negative? # => false + def negative? + self < 0 + end +end |