Class: SimpleEmoji::Index

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/simple_emoji.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(emoji_list = nil) ⇒ Index

Returns a new instance of Index.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/simple_emoji.rb', line 11

def initialize(emoji_list = nil)
  emoji_list ||= begin
    emoji_json = File.read(emoji_list_file)
    JSON.parse(emoji_json)
  end

  @emoji_list = emoji_list

  emoji_list.each do |emoji_type, emoji_type_lists|
    emoji_type_lists.each do |key, value|
      self.class.send(:define_method, "#{key}") do
        (:span, value, { class: "emoji-#{key}" }, false)
      end
    end
  end
end

Instance Attribute Details

#emoji_listObject (readonly)

Returns the value of attribute emoji_list.



9
10
11
# File 'lib/simple_emoji.rb', line 9

def emoji_list
  @emoji_list
end