System.require
uses the following loaders:
load package module relative to ./lib/* (first-party) or ./vendor/**/lib/* (third-party)
System.require('package/file')
use Ecto.Query | |
query = from w in Weather, | |
where: w.prcp > 0 or w.prcp == nil, | |
where: w.code in 27500..27599, | |
select: w | |
Repo.all(query) |
class Animal | |
attr_reader :name | |
attr_reader :family | |
def initialize(name, code) | |
@name = name | |
@family = family | |
end | |
def to_a |
# USAGE | |
Foo = class (Struct.new(:name, :address)) { | |
compare_by(:name) | |
order_by(:address, :name) | |
} |
# USAGE | |
class Foo < Struct.new(:name, :address) | |
extend HelperMacros | |
compare_by :name | |
order_by :address, :name | |
end |
class HTTP | |
def request(method, options) | |
# stuff... | |
end | |
[ | |
:get, | |
:head, | |
:put, | |
:post |
$ git clone git://github.com/rip-lang/rip.git
$ cd rip
$ bundle install
Rip comes with a command-line binary at ./bin/rip
. Type ./bin/rip help
to see how to use Rip. Specifically the current goal is to validate the generated syntax tree by trying to break the debug output. You can run .bin/rip debug -t syntax [file]
to produce a human-readable (though large) representation of the syntax tree. If you get an error, please open an issue with the exact Rip source code and a copy of the error message.
You can find out more about Rip at Rip's website (work-in-progress) and view some (hopefully still valid) examples on GitHub to get going. Please note that some examples may be outdated; pull-requests are welcome :). Also let me know if you have any trouble or are unsure about some
require 'parslet' | |
require 'pry' | |
module Rip::Compiler | |
class AST < Parslet::Transform | |
attr_reader :origin | |
def initialize(origin) | |
@origin = origin | |
end |
#!/usr/bin/env ruby | |
phrase = ARGV.first || 'I am such a tool' | |
while true | |
system "say #{phrase}" | |
sleep (1..10).to_a.sample | |
end |
class FunctionalLexer | |
TOKENS = [ | |
WhitespaceToken, | |
DigitsToken, | |
WordToken, | |
UnknownToken # keep last | |
] | |
include Enumerable |