Sha256: 8eee391fe7580b8ef29dab10a8ed2ea71817756cc78c02d84e185992571b4dd8
Contents?: true
Size: 648 Bytes
Versions: 3
Compression:
Stored size: 648 Bytes
Contents
class Cl module Merge MERGE = ->(key, lft, rgt) do lft.is_a?(Hash) && rgt.is_a?(Hash) ? lft.merge(rgt, &MERGE) : rgt end def merge(*objs) objs.inject({}) { |lft, rgt| lft.merge(rgt, &MERGE) } end end module Regex def format_regex(str) return str unless str.is_a?(Regexp) "/#{str.to_s.sub('(?-mix:', '').sub(/\)$/, '')}/" end end module Wrap def wrap(str, opts = {}) width = opts[:width] || 80 str.lines.map do |line| line.size > width ? line.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n").strip : line end.join("\n") end end extend Merge, Regex, Wrap end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cl-0.1.5 | lib/cl/helper.rb |
cl-0.1.4 | lib/cl/helper.rb |
cl-0.1.3 | lib/cl/helper.rb |