Sha256: 94cc7c5b60df6fb3c9aaefc362207db8d9ecebb6821ddc4a69e5e4c6a2529c34

Contents?: true

Size: 375 Bytes

Versions: 15

Compression:

Stored size: 375 Bytes

Contents

# frozen_string_literal: true

module AnnotateRb
  module Helper
    class << self
      def width(string)
        string.chars.inject(0) { |acc, elem| acc + ((elem.bytesize == 3) ? 2 : 1) }
      end

      # TODO: Find another implementation that doesn't depend on ActiveSupport
      def fallback(*args)
        args.compact.detect(&:present?)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
annotaterb-4.13.0 lib/annotate_rb/helper.rb
annotaterb-4.12.0 lib/annotate_rb/helper.rb
annotaterb-4.11.0 lib/annotate_rb/helper.rb
annotaterb-4.10.2 lib/annotate_rb/helper.rb
annotaterb-4.10.1 lib/annotate_rb/helper.rb
annotaterb-4.10.0 lib/annotate_rb/helper.rb
annotaterb-4.9.0 lib/annotate_rb/helper.rb
annotaterb-4.7.0 lib/annotate_rb/helper.rb
annotaterb-4.6.0 lib/annotate_rb/helper.rb
annotaterb-4.5.0 lib/annotate_rb/helper.rb
annotaterb-4.4.1 lib/annotate_rb/helper.rb
annotaterb-4.4.0 lib/annotate_rb/helper.rb
annotaterb-4.3.1 lib/annotate_rb/helper.rb
annotaterb-4.3.0 lib/annotate_rb/helper.rb
annotaterb-4.2.0 lib/annotate_rb/helper.rb