Sha256: 4f1ac58e49f3c09927e81c61378a1cd3c15a0945d7f5eb426faf44960a966b2f

Contents?: true

Size: 255 Bytes

Versions: 3

Compression:

Stored size: 255 Bytes

Contents

module StringNibbles
  def nibbles width = nil
    s = self.unpack('H*').first.scan(/(..)/).flatten
    if width
      s.in_groups_of(width).map { |group| group.join(' ') }
    else
      s.join(' ')
    end
  end
end

String.send :include, StringNibbles

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
elia-2.3.2 lib/string_nibbles.rb
elia-1.2.0 lib/string_nibbles.rb
elia-1.1.0 lib/string_nibbles.rb