GithubHelp home page GithubHelp logo

emoruby's Introduction

emoruby

Use Emojiโ„ข

A little language that compiles Emoji down to Ruby. It's just Ruby. Really.

The Language

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. (๐Ÿ„๐ŸŽฉ!)

hello world

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

procs and comments

You can also define things like Procs and comments:

๐Ÿ’ญ Comment! ๐Ÿ‘‹
๐Ÿ‘‰ ๐Ÿ”จ
 ๐Ÿ’ฌ๐Ÿ˜ƒ๐Ÿ’ฌ
๐Ÿ”šโ–ช๏ธ๐Ÿ“ž

which is equivalent to this Ruby:

# Comment! ๐Ÿ‘‹
-> do
  "smiley"
end.call

enumerables and block params

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 }

method visibility

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>

Using the gem

registering the ".emoruby" file extension

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

command line

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

API

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\""

Versioning

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 ๐Ÿ“ˆ.

emoruby's People

Contributors

krasnoukhov avatar mdoel avatar parndt avatar searls avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

emoruby's Issues

Add comments

emoruby should allow comments that begin with #๏ธโƒฃ and then ignore everything entered after the hash.

add parameter lists

right now you can only define no-arg and one-arg parameters. we need a , translation at the very least

Add modules

currently ๐Ÿ“‹ translates to "class" but we should allow modules to be defined as well

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.