diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-19 01:13:34 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-05-19 01:13:34 -0300 |
commit | 72959da5edfec80b85b28aedb880ed89e9dd77d4 (patch) | |
tree | e1b8b333791d73f78b645eecc0bb036e81c21d59 /activesupport/lib/active_support/core_ext/numeric/inquiry.rb | |
parent | bd262b05c133fa325a83b933b16c4c2748bfbe64 (diff) | |
parent | ed83f90d6124c4185a6d31010770e3c84d6be5fc (diff) | |
download | rails-72959da5edfec80b85b28aedb880ed89e9dd77d4.tar.gz rails-72959da5edfec80b85b28aedb880ed89e9dd77d4.tar.bz2 rails-72959da5edfec80b85b28aedb880ed89e9dd77d4.zip |
Merge pull request #20143 from vngrs/move_integer_positive_negative_to_numeric
Move Integer#positive? and Integer#negative? query methods to Numeric
Diffstat (limited to 'activesupport/lib/active_support/core_ext/numeric/inquiry.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/numeric/inquiry.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/numeric/inquiry.rb b/activesupport/lib/active_support/core_ext/numeric/inquiry.rb new file mode 100644 index 0000000000..b1a27dd698 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/numeric/inquiry.rb @@ -0,0 +1,19 @@ +class Numeric + # 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 |