Sha256: fc4c70151969aeedeab8230dd86da7231939f9d84478a48cb2c22a86ab8a1db0

Contents?: true

Size: 368 Bytes

Versions: 76

Compression:

Stored size: 368 Bytes

Contents

# encoding: utf-8
require 'open_classes/numeric/is_ascii'

# String
class String
  # count string size. ascii => count1, not ascii => count2
  #
  def ascii1_other2_size
    chars.to_a.reduce(0) do |sum, v|
      case v.ord
      when 65_393..65_437
        sum += 1
      when 1..127
        sum += 1
      else
        sum += 2
      end
      sum
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.131 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.130 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.129 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.128 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.127 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.126 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.125 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.124 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.123 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.122 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.121 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.120 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.119 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.118 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.117 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.116 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.115 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.114 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.113 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.112 lib/open_classes/string/ascii1_other2_size.rb