Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Extended by:
- FatCore::Numeric::ClassMethods
- Includes:
- FatCore::Numeric
- Defined in:
- lib/fat_core/numeric.rb,
lib/fat_core/patches.rb,
lib/fat_core/patches.rb more...
Instance Method Summary collapse
-
#commas(places = nil) ⇒ String
included
from FatCore::Numeric
Convert this number into a string and insert grouping commas into the whole number part and round the decimal part to
places
decimal places, with the default number of places being zero for an integer and 4 for a non-integer. -
#group(places = nil, delim = ',') ⇒ String
included
from FatCore::Numeric
Convert this number into a string and insert grouping delimiter character,
delim
into the whole number part and round the decimal part toplaces
decimal places, with the default number of places being zero for an integer and 4 for a non-integer. -
#int_if_whole ⇒ Numeric, Integer
included
from FatCore::Numeric
Return an Integer type, but only if the fractional part of self is zero; otherwise just return self.
- #negative? ⇒ Boolean
- #positive? ⇒ Boolean
-
#secs_to_hms ⇒ String
included
from FatCore::Numeric
Convert self, regarded as a number of seconds, into a string of the form HH:MM:SS.dd, that is to hours, minutes and seconds and fractions of seconds.
-
#signum ⇒ Integer
included
from FatCore::Numeric
Return the signum function for this number, i.e., 1 for a positive number, 0 for zero, and -1 for a negative number.
-
#tex_quote ⇒ Object
included
from FatCore::Numeric
Quote self for use in TeX documents.
-
#whole? ⇒ Boolean
included
from FatCore::Numeric
Return whether this is a whole number.
Instance Method Details
permalink #commas(places = nil) ⇒ String Originally defined in module FatCore::Numeric
Convert this number into a string and insert grouping commas into the
whole number part and round the decimal part to places
decimal places,
with the default number of places being zero for an integer and 4 for a
non-integer. The fractional part is padded with zeroes on the right to
come out to places
digits after the decimal place.
permalink #group(places = nil, delim = ',') ⇒ String Originally defined in module FatCore::Numeric
Convert this number into a string and insert grouping delimiter character,
delim
into the whole number part and round the decimal part to places
decimal places, with the default number of places being zero for an
integer and 4 for a non-integer. The fractional part is padded with zeroes
on the right to come out to places
digits after the decimal place. This
is the same as #commas, but allows the delimiter to be any string.
permalink #int_if_whole ⇒ Numeric, Integer Originally defined in module FatCore::Numeric
Return an Integer type, but only if the fractional part of self is zero; otherwise just return self.
permalink #negative? ⇒ Boolean
12 13 14 |
# File 'lib/fat_core/patches.rb', line 12 def negative? self < 0 end |
permalink #positive? ⇒ Boolean
4 5 6 |
# File 'lib/fat_core/patches.rb', line 4 def positive? self > 0 end |
permalink #secs_to_hms ⇒ String Originally defined in module FatCore::Numeric
Convert self, regarded as a number of seconds, into a string of the form HH:MM:SS.dd, that is to hours, minutes and seconds and fractions of seconds.
permalink #signum ⇒ Integer Originally defined in module FatCore::Numeric
Return the signum function for this number, i.e., 1 for a positive number, 0 for zero, and -1 for a negative number.
permalink #tex_quote ⇒ Object Originally defined in module FatCore::Numeric
Quote self for use in TeX documents. Since number components are not
special to TeX, this just applies #to_s
permalink #whole? ⇒ Boolean Originally defined in module FatCore::Numeric
Return whether this is a whole number.