class Numeric
Copyright Freya Dorn <freya.siv.dorn@gmail.com>, 2017 License: GNU APGLv3 (or later) <www.gnu.org/copyleft/gpl.html>
Copyright Freya Dorn <freya.siv.dorn@gmail.com>, 2017 License: GNU APGLv3 (or later) <www.gnu.org/copyleft/gpl.html>
Constants
- DELIMITER_REGEX
Public Instance Methods
blank?()
click to toggle source
# File lib/muflax/blank.rb, line 16 def blank? ; false ; end
days()
click to toggle source
# File lib/muflax/time.rb, line 11 def days ; self.hours * 24 ; end
Also aliased as: day
delimit(delimiter="_")
click to toggle source
# File lib/muflax/num.rb, line 21 def delimit delimiter="_" left, right = self.to_s.split(".") left.gsub!(DELIMITER_REGEX) do |digit_to_delimit| "#{digit_to_delimit}#{delimiter}" end [left, right].compact.join(".") end
duplicable?()
click to toggle source
# File lib/muflax/deep_dup.rb, line 43 def duplicable? ; false ; end
factorial()
click to toggle source
# File lib/muflax/num.rb, line 36 def factorial Math.factorial self end
factors()
click to toggle source
# File lib/muflax/num.rb, line 40 def factors (1..self).select{|f| self.multiple_of? f} end
fortnights()
click to toggle source
# File lib/muflax/time.rb, line 13 def fortnights ; self.weeks * 2 ; end
Also aliased as: fortnight
hours()
click to toggle source
# File lib/muflax/time.rb, line 10 def hours ; self.minutes * 60 ; end
Also aliased as: hour
milliseconds()
click to toggle source
# File lib/muflax/time.rb, line 7 def milliseconds ; self.seconds / 1000.0 ; end
Also aliased as: millisecond
minutes()
click to toggle source
# File lib/muflax/time.rb, line 9 def minutes ; self.seconds * 60 ; end
Also aliased as: minute
months()
click to toggle source
# File lib/muflax/time.rb, line 14 def months ; self.days * 30 ; end
Also aliased as: month
multiple_of?(number)
click to toggle source
# File lib/muflax/num.rb, line 15 def multiple_of?(number) number != 0 ? self % number == 0 : zero? end
prime?()
click to toggle source
# File lib/muflax/num.rb, line 30 def prime? return false if self < 2 not (2..(Math.sqrt(self))).any?{|f| self.multiple_of? f} end
round_into(num)
click to toggle source
# File lib/muflax/num.rb, line 7 def round_into num ((self / num) / num + 1) * num end
round_to(num)
click to toggle source
# File lib/muflax/num.rb, line 11 def round_to num (self / num.to_f).round * num end
seconds()
click to toggle source
# File lib/muflax/time.rb, line 8 def seconds ; self ; end
Also aliased as: second
weeks()
click to toggle source
# File lib/muflax/time.rb, line 12 def weeks ; self.days * 7 ; end
Also aliased as: week
years()
click to toggle source
# File lib/muflax/time.rb, line 15 def years ; self.days * 365 ; end
Also aliased as: year