Elixir.rb
The Elixir standard library in Ruby!
So far there are partial implementations of the following Elixir modules:
- Agent
- Atom
- Base
- Dict
- Enum
- File
- Float
- Integer
- List
- OptionParser
- Path
- Range
- Set
- Stream
- String
- System
- Task
- Tuple
- Version
Installation
gem install elixir.rb
Examples
require 'elixir/stream'
include Elixir
Fib = Stream.unfold [0, 1] do |a, b|
[a, [b, a + b]]
end
Fib.size
#=> Infinity
Fib.take 5
#=> [0, 1, 1, 2, 3]
require 'elixir/agent'
require 'elixir/task'
include Elixir
status, agent = Agent.start { 0 }
#=> [:ok, #<Concurrent::Atomic:...>]
Agent.cast(agent) { |value| value + 42 }
#=> :ok
Agent.get(agent, &:next)
#=> 43
task = Task.async ->{ sleep 0.5; Agent.get(agent, &:itself) }
#<Concurrent::IVar:...>
Task.await(task)
#=> 42
Requirements
Ruby 2.2+
Development
Install Elixir.rb and its deps:
git clone https://github.com/havenwood/elixir.rb
cd elixir.rb
gem install -g --no-lock
Run the tests:
rake