Sha256: dc897f367fd8f8f2d2a474d88f0de8e0283a202f770c5bc53a745d236233fe3e
Contents?: true
Size: 695 Bytes
Versions: 1
Compression:
Stored size: 695 Bytes
Contents
# frozen_string_literal: true module WSDirector module Ext # Extend Object through refinements module Formatting refine ::Object do def truncate(*__rest__) ; itself; end end refine ::String do def truncate(limit) return self if size <= limit "#{self[0..(limit - 3)]}..." end end refine ::Hash do def truncate(limit) str = to_json str.truncate(limit) end end refine ::Float do def duration if self > 1 "#{truncate(2)}s" else "#{(self * 1000).to_i}ms" end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wsdirector-core-1.1.0 | lib/.rbnext/3.0/wsdirector/ext/formatting.rb |