Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/core/numeric.rb
Instance Method Summary collapse
Instance Method Details
#evenize(operator = '+') ⇒ Object
3 4 5 6 |
# File 'lib/core/numeric.rb', line 3 def evenize(operator = '+') raise ArgumentError, "invalid argument (must be `+' or `-')" unless %w(+ -).include?(operator) round.send(operator, modulo(2)) end |
#oddize(operator = '+') ⇒ Object
8 9 10 11 |
# File 'lib/core/numeric.rb', line 8 def oddize(operator = '+') raise ArgumentError, "invalid argument (must be `+' or `-')" unless %w(+ -).include?(operator) self %2 > 0 ? self : round.send(operator, 1) end |