Sha256: 6b8ecf085bbe84893b41e2d0ce08881245858a56d78748e3d84612f25fa7467c

Contents?: true

Size: 632 Bytes

Versions: 5

Compression:

Stored size: 632 Bytes

Contents

# Copyright 2018 Twitter, Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0

# encoding: UTF-8

module Twitter
  module TwitterText
    class WeightedRange
      attr_reader :start, :end, :weight

      def initialize(range = {})
        raise ArgumentError.new("Invalid range") unless [:start, :end, :weight].all? { |key| range.key?(key) && range[key].is_a?(Integer) }
        @start = range[:start]
        @end = range[:end]
        @weight = range[:weight]
      end

      def contains?(code_point)
        code_point >= @start && code_point <= @end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 4 rubygems

Version Path
twitter-text-kow-1.3.1.0 lib/twitter-text/weighted_range.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/twitter-text-3.1.0/lib/twitter-text/weighted_range.rb
twitter-text-3.1.0 lib/twitter-text/weighted_range.rb
twitter-text-simpleidn-3.0.0.0 lib/twitter-text/weighted_range.rb
twitter-text-3.0.0 lib/twitter-text/weighted_range.rb