Class: Somemoji::Emoji
- Inherits:
-
Object
- Object
- Somemoji::Emoji
- Defined in:
- lib/somemoji/emoji.rb
Instance Attribute Summary collapse
- #aliases ⇒ Array<String> readonly
- #ascii_arts ⇒ Array<String> readonly
- #category ⇒ String? readonly
- #code ⇒ String? readonly
- #code_points ⇒ Array<String>? readonly
- #keywords ⇒ Array<String>? readonly
- #name ⇒ String? readonly
Instance Method Summary collapse
- #abbreviated_code_points ⇒ Array<String>
- #base_path ⇒ String
-
#character ⇒ String?
A String representation from its code points.
-
#initialize(aliases: nil, ascii_arts: nil, category: nil, code:, code_points: nil, keywords: nil, name: nil) ⇒ Emoji
constructor
A new instance of Emoji.
- #to_hash ⇒ Hash{Symbol => Object}
Constructor Details
#initialize(aliases: nil, ascii_arts: nil, category: nil, code:, code_points: nil, keywords: nil, name: nil) ⇒ Emoji
Returns a new instance of Emoji.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/somemoji/emoji.rb', line 60 def initialize( aliases: nil, ascii_arts: nil, category: nil, code:, code_points: nil, keywords: nil, name: nil ) @aliases = aliases || [] @ascii_arts = ascii_arts || [] @category = category @code = code @code_points = code_points || [] @keywords = keywords || [] @name = name end |
Instance Attribute Details
#aliases ⇒ Array<String> (readonly)
4 5 6 |
# File 'lib/somemoji/emoji.rb', line 4 def aliases @aliases end |
#ascii_arts ⇒ Array<String> (readonly)
7 8 9 |
# File 'lib/somemoji/emoji.rb', line 7 def ascii_arts @ascii_arts end |
#category ⇒ String? (readonly)
10 11 12 |
# File 'lib/somemoji/emoji.rb', line 10 def category @category end |
#code ⇒ String? (readonly)
13 14 15 |
# File 'lib/somemoji/emoji.rb', line 13 def code @code end |
#code_points ⇒ Array<String>? (readonly)
16 17 18 |
# File 'lib/somemoji/emoji.rb', line 16 def code_points @code_points end |
#keywords ⇒ Array<String>? (readonly)
19 20 21 |
# File 'lib/somemoji/emoji.rb', line 19 def keywords @keywords end |
#name ⇒ String? (readonly)
22 23 24 |
# File 'lib/somemoji/emoji.rb', line 22 def name @name end |
Instance Method Details
#abbreviated_code_points ⇒ Array<String>
79 80 81 82 83 |
# File 'lib/somemoji/emoji.rb', line 79 def abbreviated_code_points code_points.reject do |code_point| %w(200d fe0f).include?(code_point.downcase) end end |
#base_path ⇒ String
86 87 88 89 90 91 92 |
# File 'lib/somemoji/emoji.rb', line 86 def base_path if code_points.empty? code else "unicode/#{code_points.join('-')}" end end |
#character ⇒ String?
Returns a String representation from its code points.
95 96 97 98 99 100 101 |
# File 'lib/somemoji/emoji.rb', line 95 def character unless code_points.empty? code_points.map do |code_point| code_point.to_i(16) end.pack("U*") end end |
#to_hash ⇒ Hash{Symbol => Object}
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/somemoji/emoji.rb', line 104 def to_hash { aliases: aliases, ascii_arts: ascii_arts, category: category, code: code, code_points: code_points, keywords: keywords, name: name, } end |