class UnicodeRange

Constants

VERSION

Attributes

from[R]
to[R]

Public Class Methods

new(from:, to:) click to toggle source
# File lib/unicode_range.rb, line 5
def initialize(from:, to:)
  @from = from.to_i(16)
  @to = to.to_i(16)
end

Public Instance Methods

expand(except: []) click to toggle source
# File lib/unicode_range.rb, line 10
def expand(except: [])
  Collection.new codepoints(except)
end

Private Instance Methods

casecmp(x, y) click to toggle source
# File lib/unicode_range.rb, line 28
def casecmp(x, y)
  x.casecmp(y) == 0
end
codepoints(except) click to toggle source
# File lib/unicode_range.rb, line 18
def codepoints(except)
  [*from..to].select do |codepoint|
    not except.any? { |exclude| casecmp(to_hex(codepoint), exclude) }
  end
end
to_hex(int) click to toggle source
# File lib/unicode_range.rb, line 24
def to_hex(int)
  int.to_s(16)
end