Sha256: fec46ce99a35e5a5b5b1b06940277b8ba95dd5af0e0d4b09be3e3b1eb80abbad
Contents?: true
Size: 733 Bytes
Versions: 1
Compression:
Stored size: 733 Bytes
Contents
require "transproc/version" module Transproc def self.register(*args, &block) name, fn = *args functions[name] = fn || block end def self.functions @_functions ||= {} end def self.[](name) functions.fetch(name) end class Function attr_reader :fn, :args def initialize(fn, args = []) @fn = fn @args = args end def call(value) fn[value, *args] end alias_method :[], :call def compose(other) self.class.new(-> value { other[fn[value]] }) end alias_method :+, :compose end end def Transproc(fn, *args) case fn when Proc then Transproc::Function.new(fn, args) when Symbol then Transproc::Function.new(Transproc[fn], args) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
transproc-0.0.1 | lib/transproc.rb |