Sha256: 191b5f3a5058b7d760a06eb62df5d42eb0fec0a3a5cdbff24a11ea084014757c

Contents?: true

Size: 277 Bytes

Versions: 8

Compression:

Stored size: 277 Bytes

Contents

#! /usr/bin/env ruby
# coding: utf-8

class String
  # Return character width in rxvt-unicode.
  def width
    chars = ' -~' + '’”' # width of one alphabetic char.
    num_ascii = count(chars)
    num_wide = size - num_ascii
    return 2 * num_wide + num_ascii
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
builtinextension-0.1.4 lib/string/width.rb
builtinextension-0.1.3 lib/string/width.rb
builtinextension-0.1.2 lib/string/width.rb
builtinextension-0.1.1 lib/string/width.rb
builtinextension-0.1.0 lib/string/width.rb
builtinextension-0.0.5 lib/string_width.rb
builtinextension-0.0.4 lib/string_width.rb
builtinextension-0.0.3 lib/string_width.rb