A little language that compiles Emoji down to Ruby. It's just Ruby. Really.
If I were a real language designer, I would have put a lot of thought into the syntax, semantics, and structure of emoruby. Instead I basically implemented an inefficient find-and-replace from a static dictionary. (๐๐ฉ!)
Anyway, here is an example hello world program:
๐ โค๏ธ
๐ ๐
๐ ๐ฌ๐ ๐๐ฌ
๐
๐
โค๏ธโช๏ธ๐ฃโช๏ธ๐
which is equivalent to this Ruby:
class Heart
def wave
puts "smiley earth_asia"
end
end
Heart.new.wave
You can also define things like Procs and comments:
๐ญ Comment! ๐
๐ ๐จ
๐ฌ๐๐ฌ
๐โช๏ธ๐
which is equivalent to this Ruby:
# Comment! ๐
-> do
"smiley"
end.call
You can also define Array and Hash literals, and use the {}
block syntax:
โ๏ธ9๏ธโฃโฐ3๏ธโฃโถ๏ธโช๏ธ๐ โช ๐๐
ฐ๐ ๐
ฐ โ 1 โฉ
Which translates to this Ruby:
[9,3].map { |a| a + 1 }
You can define private and protected methods:
๐ โค๏ธ
๐ ๐ ๐
๐ ๐ฌ๐๐ฌ
๐
๐๏ธ ๐ ๐
๐ ๐ฌ๐๐ฌ
๐
โ๏ธ ๐ ๐
๐ ๐ฌ๐ ๐๐ฌ
๐
๐
โค๏ธโช๏ธ๐ฃโช๏ธ๐
which is equivalent to this Ruby:
class Heart
public def jeans
puts "purse"
end
protected def shirt
puts "yellow_heart"
end
private def wave
puts "smiley earth_asia"
end
end
Heart.new.wave
Which will result in an exception:
NoMethodError: private method `wave' called for #<Heart:0x007f81eb840138>
Emoruby uses polyglot to enable require
to be used on .emoruby
files just as you do with Ruby source .rb
files. To register the file extension, simply:
> require 'emoruby'
=> true
> Emoruby.register
=> nil
> require 'hello_world'
smiley earth_asia
=> true
You can run emoruby from the command line by passing an emoruby file as the first argument:
$ emoruby spec/fixtures/1_hello_world.emoruby
smiley earth_asia
The API allows both evaluation of emoruby code as well as translation to Ruby.
> source = "๐ฌ๐ ๐๐ฌ"
=> "๐ฌ๐ ๐๐ฌ"
> Emoruby.eval(source)
=> "smiley earth_asia"
Emoruby.emoji_to_ruby(source)
=> "\"smiley earth_asia\""
The Emoruby team embraces and advocates the adoption of the the emerging emotional versioning standard ("emover" for short).
The initial release was ๐ฉ (in honor of @tenderlove's ๐ฉ-lang). After that, โ was released. Then came ๐ท. The next planned release is ๐.