Ruby for Node
Helper methods from ruby ported to Node.

Getting Started

npm install ruby --save
let r = require('ruby');

let words = r.w('I am not throwing away my shot!');
words; // ['I', 'am', 'not', 'throwing', 'away', 'my', 'shot!']

$stdout - Docs

A collection of methods that output to stdout. All the methods are available both on the $stdout object and as standalone methods.

    this.$stdout = new $Stdout();
    assign(this, this.$stdout);
    this.int = new _Integer();
    this.str = new _String();

Percent Strings - Docs

    assign(this, new PercentStrings());

add_methods_to_number_prototype

If you’d like the Integer Methods as attributes on any number, just run this method.

ruby.add_methods_to_number_prototype();
  add_methods_to_number_prototype () {
    _addMethodsToPrototype(Number.prototype, this.int);
  }

add_methods_to_string_prototype

If you’d like the String Methods as attributes on any string, just run this method.

ruby.add_methods_to_string_prototype();
  add_methods_to_string_prototype () {
    _addMethodsToPrototype(String.prototype, this.str);
  }

More than one argument indicates that the second is a block

    if (method.length > 1) {
      prototype[method_name] = _generate_method_with_block(method);
    } else {
      Object.defineProperty(
        prototype,
        method_name,
        { get: method }
      );
    }
  });
}

export default new Ruby();