Class: Emojidex::Emoji

Inherits:
Object
  • Object
show all
Includes:
EmojiAssetInformation
Defined in:
lib/emojidex/emoji.rb

Overview

emoji base class

Instance Attribute Summary collapse

Attributes included from EmojiAssetInformation

#checksums, #paths

Instance Method Summary collapse

Methods included from EmojiAssetInformation

#checksum?, #path?

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
  @tags = details[:tags].map { |tag| tag.to_sym } unless details[:tags].nil?
  @link = details[:link]
  @is_wide = details[:is_wide]
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



6
7
8
# File 'lib/emojidex/emoji.rb', line 6

def category
  @category
end

#codeObject

Returns the value of attribute code.



6
7
8
# File 'lib/emojidex/emoji.rb', line 6

def code
  @code
end

#code_jaObject

Returns the value of attribute code_ja.



6
7
8
# File 'lib/emojidex/emoji.rb', line 6

def code_ja
  @code_ja
end

#emoticonObject

Returns the value of attribute emoticon.



6
7
8
# File 'lib/emojidex/emoji.rb', line 6

def emoticon
  @emoticon
end

#mojiObject

Returns the value of attribute moji.



6
7
8
# File 'lib/emojidex/emoji.rb', line 6

def moji
  @moji
end

#tagsObject

Returns the value of attribute tags.



6
7
8
# File 'lib/emojidex/emoji.rb', line 6

def tags
  @tags
end

#unicodeObject

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_hashObject



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_sObject



22
23
24
# File 'lib/emojidex/emoji.rb', line 22

def to_s
  @moji || ":#{@code}:"
end