lib/unicode/emoji.rb in unicode-emoji-0.9.3 vs lib/unicode/emoji.rb in unicode-emoji-1.0.0
- old
+ new
@@ -29,11 +29,11 @@
VALID_REGION_FLAGS = INDEX[:FLAGS].freeze
VALID_SUBDIVISIONS = INDEX[:SD].freeze
RECOMMENDED_SUBDIVISION_FLAGS = INDEX[:TAGS].freeze
RECOMMENDED_ZWJ_SEQUENCES = INDEX[:ZWJ].freeze
- LIST = INDEX[:LIST].freeze.each{ |_, sub_list| sub_list.freeze }
+ LIST = INDEX[:LIST].freeze.each_value(&:freeze)
pack = ->(ord){ Regexp.escape(Array(ord).pack("U*")) }
join = -> (*strings){ "(?:" + strings.join("|") + ")" }
pack_and_join = ->(ords){ join[*ords.map{ |ord| pack[ord] }] }
@@ -136,18 +136,11 @@
# nothing
end
end
def self.list(key = nil, sub_key = nil)
- if key
- if sub_key
- LIST[key][sub_key]
- else
- LIST[key]
- end
- else
- LIST
- end
+ return LIST unless key || sub_key
+ LIST.dig(*[key, sub_key].compact)
end
def self.get_codepoint_value(char)
ord = nil