Class: Numeric
- Includes:
- Comparable
- Defined in:
- ext/enterprise_script_service/mruby/mrblib/numeric.rb,
ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb,
ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb
Overview
Numeric
ISO 15.2.7
Direct Known Subclasses
Instance Method Summary collapse
-
#+@ ⇒ Object
Returns the receiver simply.
-
#-@ ⇒ Object
Returns the receiver’s value, negated.
-
#abs ⇒ Object
Returns the absolute value of the receiver.
- #negative? ⇒ Boolean
- #nonzero? ⇒ Boolean
- #positive? ⇒ Boolean
- #to_r ⇒ Object
- #zero? ⇒ Boolean
Methods included from Comparable
#<, #<=, #==, #>, #>=, #between?, #clamp
Instance Method Details
#+@ ⇒ Object
Returns the receiver simply.
ISO 15.2.7.4.1
11 12 13 |
# File 'ext/enterprise_script_service/mruby/mrblib/numeric.rb', line 11 def +@ self end |
#-@ ⇒ Object
Returns the receiver’s value, negated.
ISO 15.2.7.4.2
19 20 21 |
# File 'ext/enterprise_script_service/mruby/mrblib/numeric.rb', line 19 def -@ 0 - self end |
#abs ⇒ Object
Returns the absolute value of the receiver.
ISO 15.2.7.4.3
27 28 29 30 31 32 33 |
# File 'ext/enterprise_script_service/mruby/mrblib/numeric.rb', line 27 def abs if self < 0 -self else self end end |
#negative? ⇒ Boolean
18 19 20 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb', line 18 def negative? self < 0 end |
#nonzero? ⇒ Boolean
6 7 8 9 10 11 12 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb', line 6 def nonzero? if self == 0 nil else self end end |
#positive? ⇒ Boolean
14 15 16 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb', line 14 def positive? self > 0 end |
#to_r ⇒ Object
80 81 82 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb', line 80 def to_r Rational(self, 1) end |
#zero? ⇒ Boolean
2 3 4 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb', line 2 def zero? self == 0 end |