Sha256: d747da757caf3144d52159598b8be8195880e87e672520ebe590783ffe52d990

Contents?: true

Size: 455 Bytes

Versions: 3

Compression:

Stored size: 455 Bytes

Contents

# encoding: UTF-8

module Twitter
  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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
twitter-text-2.0.2 lib/twitter-text/weighted_range.rb
twitter-text-2.0.1 lib/twitter-text/weighted_range.rb
twitter-text-2.0.0 lib/twitter-text/weighted_range.rb