Sha256: 3b03ab1b8973712b7b56369d02d2f623b38f4fa5e99ab900bc7fb0c4856d6ea6

Contents?: true

Size: 822 Bytes

Versions: 1

Compression:

Stored size: 822 Bytes

Contents

require_relative "sequence_name/constants"

module Unicode
  module SequenceName
    def self.sequence_name(string)
      codepoints = get_codepoint_values(string)
      require_relative "sequence_name/index" unless defined? ::Unicode::SequenceName::INDEX
      if res = INDEX[:SEQUENCES][codepoints]
        res
      else
        nil
      end
    end
    class << self; alias of sequence_name; end

    def self.get_codepoint_values(string)
      if string.valid_encoding?
        return string.codepoints
      elsif string.encoding.name == "UTF-8"
        begin
          return string.unpack("U*")
        rescue ArgumentError
        end
      end

      raise(ArgumentError, "Unicode::SequenceName.of must be given a valid string")
    end

    class << self
      private :get_codepoint_values
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unicode-sequence_name-1.14.1 lib/unicode/sequence_name.rb