Sha256: 3fca16cec37408b799c1f9b70e1f95fc55c915c15f464e6c8937a72851832a8f
Contents?: true
Size: 660 Bytes
Versions: 1
Compression:
Stored size: 660 Bytes
Contents
module Holistics module Utils class << self COLORIZE_MAPPING = { green: %w{active success ok}, red: %w{fail failure error cancelled}, yellow: %w{new pending unknown} } def colorize(text) color = COLORIZE_MAPPING.find { |color, values| values.include?(text) } color ? text.method(color[0]).call : text end def duration secs [[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name| if secs > 0 secs, n = secs.divmod(count) "#{n.to_i} #{name}" end }.compact.reverse.join(' ') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
holistics-cli-0.1.1 | lib/holistics/utils.rb |