lib/unicode/sequence_name.rb in unicode-sequence_name-1.15.0 vs lib/unicode/sequence_name.rb in unicode-sequence_name-1.15.1
- old
+ new
@@ -4,22 +4,22 @@
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] || INDEX[:SEQUENCES_NOT_QUALIFIED][codepoints]
- res
+ insert_words(res)
else
nil
end
end
class << self; alias of sequence_name; end
def self.fully_qualified(string)
codepoints = get_codepoint_values(string)
require_relative "sequence_name/index" unless defined? ::Unicode::SequenceName::INDEX
if res = INDEX[:SEQUENCES][codepoints]
- res
+ insert_words(res)
else
nil
end
end
@@ -34,11 +34,23 @@
end
raise(ArgumentError, "Unicode::SequenceName.of must be given a valid string")
end
+ def self.insert_words(raw_name)
+ raw_name.chars.map{ |char|
+ codepoint = char.ord
+ if codepoint < INDEX[:REPLACE_BASE]
+ char
+ else
+ "#{INDEX[:COMMON_WORDS][codepoint - INDEX[:REPLACE_BASE]]} "
+ end
+ }.join.chomp
+ end
+
class << self
private :get_codepoint_values
+ private :insert_words
end
end
end