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.151 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.150 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.149 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.148 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.147 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.146 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.145 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.144 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.143 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.142 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.141 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.140 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.139 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.138 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.137 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.136 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.135 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.134 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.133 lib/open_classes/string/ascii1_other2_size.rb
tbpgr_utils-0.0.132 lib/open_classes/string/ascii1_other2_size.rb