Sha256: 60131b1fd22d48f198c29ad0fbbe30c1f32c1acfc6820fe7b196303b8ef1b72f

Contents?: true

Size: 810 Bytes

Versions: 18

Compression:

Stored size: 810 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[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

18 entries across 18 versions & 1 rubygems

Version Path
unicode-sequence_name-1.14.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.13.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.12.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.11.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.10.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.9.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.8.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.7.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.6.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.5.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.4.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.3.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.2.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.1.2 lib/unicode/sequence_name.rb
unicode-sequence_name-1.1.1 lib/unicode/sequence_name.rb
unicode-sequence_name-1.1.0 lib/unicode/sequence_name.rb
unicode-sequence_name-1.0.1 lib/unicode/sequence_name.rb
unicode-sequence_name-1.0.0 lib/unicode/sequence_name.rb