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
day()
Alias for: days
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
fortnight()
Alias for: fortnights
fortnights() click to toggle source
# File lib/muflax/time.rb, line 13
def fortnights        ; self.weeks         * 2           ; end
Also aliased as: fortnight
hour()
Alias for: hours
hours() click to toggle source
# File lib/muflax/time.rb, line 10
def hours             ; self.minutes       * 60          ; end
Also aliased as: hour
millisecond()

singular usage

Alias for: milliseconds
milliseconds() click to toggle source
# File lib/muflax/time.rb, line 7
def milliseconds      ; self.seconds       / 1000.0      ; end
Also aliased as: millisecond
minute()
Alias for: minutes
minutes() click to toggle source
# File lib/muflax/time.rb, line 9
def minutes           ; self.seconds       * 60          ; end
Also aliased as: minute
month()
Alias for: months
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
second()
Alias for: seconds
seconds() click to toggle source
# File lib/muflax/time.rb, line 8
def seconds           ; self                             ; end
Also aliased as: second
week()
Alias for: weeks
weeks() click to toggle source
# File lib/muflax/time.rb, line 12
def weeks             ; self.days          * 7           ; end
Also aliased as: week
year()
Alias for: years
years() click to toggle source
# File lib/muflax/time.rb, line 15
def years             ; self.days          * 365         ; end
Also aliased as: year