Skip to content

Conversation

elektronaut
Copy link
Contributor

This adds support for having custom emojis that aren't PNG files. In other words - you can now have animated GIFs.

Usage:

emoji = Emoji.create("music") do |char|
  char.set_format "gif"
end

emoji.image_filename # => "music.gif"

@mislav
Copy link
Contributor

mislav commented Dec 12, 2014

Nice direction! We definitely need this customizable. I'll think about this API some more— I feel that it might be easier and more flexible for our users to just have the entire filename for the custom emoji customizable instead of just the extension. What do you think?

@elektronaut
Copy link
Contributor Author

I definitively agree, that would be much better.

Personally, I think making image_filename behave like an attribute would be the most Ruby-like solution. Then again, everything else on Character behaves like commands, so it might look weird.

class Emoji::Character
  attr_accessor :image_filename

  def image_filename
    @image_filename || default_image_filename
  end

  private

  def default_image_filename
    if custom?
      '%s.png' % name
    else
      'unicode/%s.png' % hex_inspect.sub(/-fe0f\b/, '')
    end
  end
end

@mislav
Copy link
Contributor

mislav commented Dec 12, 2014

How about we just do that? Looks solid.

@elektronaut
Copy link
Contributor Author

👍

I've updated the pull request.


```ruby
emoji = Emoji.create("music") do |char|
char.image_filename = "my_emoji.png"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change that to subdirectory/my_emoji.gif to demonstrate that you can both add directory paths as well as change the extension

@elektronaut
Copy link
Contributor Author

All good points, I've amended the commit.

mislav added a commit that referenced this pull request Dec 12, 2014
@mislav mislav merged commit b841e20 into github:master Dec 12, 2014
@mislav
Copy link
Contributor

mislav commented Dec 12, 2014

Cool thanks! 👍

@elektronaut
Copy link
Contributor Author

🎉 Thank you!

@elektronaut elektronaut deleted the add-gif-support branch February 5, 2015 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants