Sha256: 28c04fe2e8137029b29d37ada1faa462299242512fa3bbbd5f40a25eb2fd83bd
Contents?: true
Size: 499 Bytes
Versions: 2
Compression:
Stored size: 499 Bytes
Contents
class Numeric include ErrorHelper Alpha26 = ("a".."z").to_a def to_s26 return "" if self < 1 s, q = "", self loop do q, r = (q - 1).divmod(26) s.prepend(Alpha26[r]) break if q.zero? end s end def safe_percent(part) if self > 0 if part >= 0 return 100*part.to_f/self.to_f else raise_positive_number_only end elsif self == 0 return 0 else raise_positive_number_only end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
creative_rails_utilities-0.1.2 | lib/creative_rails_utilities/numeric.rb |
creative_rails_utilities-0.1.1 | lib/creative_rails_utilities/numeric.rb |