Class: Rumoji::Emoji
- Inherits:
-
Object
- Object
- Rumoji::Emoji
- Defined in:
- lib/rumoji/emoji.rb,
lib/rumoji/emoji/nature.rb,
lib/rumoji/emoji/people.rb,
lib/rumoji/emoji/places.rb,
lib/rumoji/emoji/objects.rb,
lib/rumoji/emoji/symbols.rb
Constant Summary collapse
- ALL =
PEOPLE | NATURE | OBJECTS | PLACES | SYMBOLS
- NATURE =
Set[ self.new("\u{2600}" , [:sunny]
- PEOPLE =
Set[ self.new("\u{1F604}", [:smile]
- PLACES =
Set[ self.new("\u{1f6a1}", [:aerial_tramway]
- OBJECTS =
Set[ self.new("\u{1F38D}", [:bamboo]
- SYMBOLS =
Set[ self.new("\u{1f4af}", [:"100"]
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #code ⇒ Object
- #hash ⇒ Object
- #hex ⇒ Object
- #include?(symbol) ⇒ Boolean
-
#initialize(string, symbols, name = nil) ⇒ Emoji
constructor
A new instance of Emoji.
- #symbol ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(string, symbols, name = nil) ⇒ Emoji
Returns a new instance of Emoji.
7 8 9 10 11 |
# File 'lib/rumoji/emoji.rb', line 7 def initialize(string, symbols, name = nil) @codepoints = string.codepoints @cheat_codes = [symbols].flatten @name = name || @cheat_codes.first.to_s.upcase.gsub("_", " ") end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/rumoji/emoji.rb', line 5 def name @name end |
Class Method Details
.find(symbol) ⇒ Object
45 46 47 |
# File 'lib/rumoji/emoji.rb', line 45 def self.find(symbol) ALL.find {|emoji| emoji.include? symbol } end |
Instance Method Details
#code ⇒ Object
17 18 19 |
# File 'lib/rumoji/emoji.rb', line 17 def code ":#{symbol}:" end |
#hash ⇒ Object
29 30 31 |
# File 'lib/rumoji/emoji.rb', line 29 def hash code.hash end |
#hex ⇒ Object
33 34 35 |
# File 'lib/rumoji/emoji.rb', line 33 def hex @codepoints.map{|point| point.to_s(16).upcase }.join("-") end |
#include?(symbol) ⇒ Boolean
21 22 23 |
# File 'lib/rumoji/emoji.rb', line 21 def include?(symbol) @cheat_codes.include? symbol.to_sym end |
#symbol ⇒ Object
13 14 15 |
# File 'lib/rumoji/emoji.rb', line 13 def symbol @cheat_codes.first end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/rumoji/emoji.rb', line 25 def to_s @codepoints.to_a.pack("U*") end |