Class: Emojidex::Emoji
- Inherits:
-
Object
- Object
- Emojidex::Emoji
- Includes:
- EmojiAssetInformation
- Defined in:
- lib/emojidex/emoji.rb
Overview
emoji base class
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#code ⇒ Object
Returns the value of attribute code.
-
#code_ja ⇒ Object
Returns the value of attribute code_ja.
-
#emoticon ⇒ Object
Returns the value of attribute emoticon.
-
#moji ⇒ Object
Returns the value of attribute moji.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#unicode ⇒ Object
Returns the value of attribute unicode.
Attributes included from EmojiAssetInformation
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
-
#initialize(details = {}) ⇒ Emoji
constructor
A new instance of Emoji.
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
- #to_s ⇒ Object
Methods included from EmojiAssetInformation
Constructor Details
#initialize(details = {}) ⇒ Emoji
Returns a new instance of Emoji.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/emojidex/emoji.rb', line 11 def initialize(details = {}) @moji = details[:moji] @code, @code_ja = details[:code], details[:code_ja] @unicode, @full_name = details[:unicode], details[:full_name] @emoticon = details[:emoticon] @category = details[:category] ? details[:category].to_sym : :other = details[:tags].map { |tag| tag.to_sym } unless details[:tags].nil? @link = details[:link] @is_wide = details[:is_wide] end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
6 7 8 |
# File 'lib/emojidex/emoji.rb', line 6 def category @category end |
#code ⇒ Object
Returns the value of attribute code.
6 7 8 |
# File 'lib/emojidex/emoji.rb', line 6 def code @code end |
#code_ja ⇒ Object
Returns the value of attribute code_ja.
6 7 8 |
# File 'lib/emojidex/emoji.rb', line 6 def code_ja @code_ja end |
#emoticon ⇒ Object
Returns the value of attribute emoticon.
6 7 8 |
# File 'lib/emojidex/emoji.rb', line 6 def emoticon @emoticon end |
#moji ⇒ Object
Returns the value of attribute moji.
6 7 8 |
# File 'lib/emojidex/emoji.rb', line 6 def moji @moji end |
#tags ⇒ Object
Returns the value of attribute tags.
6 7 8 |
# File 'lib/emojidex/emoji.rb', line 6 def end |
#unicode ⇒ Object
Returns the value of attribute unicode.
6 7 8 |
# File 'lib/emojidex/emoji.rb', line 6 def unicode @unicode end |
Instance Method Details
#[](key) ⇒ Object
38 39 40 |
# File 'lib/emojidex/emoji.rb', line 38 def [](key) instance_variable_get(key.to_s.delete(':').insert(0, '@')) end |
#[]=(key, val) ⇒ Object
42 43 44 |
# File 'lib/emojidex/emoji.rb', line 42 def []=(key, val) instance_variable_set(key.to_s.delete(':').insert(0, '@'), val) end |
#to_hash ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/emojidex/emoji.rb', line 30 def to_hash hash = {} instance_variables.each do |key| hash[key.to_s.delete('@')] = instance_variable_get(key) end hash end |
#to_json(*args) ⇒ Object
26 27 28 |
# File 'lib/emojidex/emoji.rb', line 26 def to_json(*args) to_hash.to_json(*args) end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/emojidex/emoji.rb', line 22 def to_s @moji || ":#{@code}:" end |