Sha256: b0982935fa6249e2ed673a1f695618c47a09fe436532cbac534adae363c3318d
Contents?: true
Size: 724 Bytes
Versions: 2
Compression:
Stored size: 724 Bytes
Contents
module Funkr # Should not be used directly class Matcher def initialize(match) @const, *@data = match @runner = nil @undefined = self.class.constructs.clone end def self.build_matchers(constructs) @constructs = constructs constructs.each do |c| name, *data = c define_method(name) do |&b| @undefined.delete(name) if @const == name then @runner = b end end end end def self.constructs; @constructs; end def run_match if @undefined.any? then raise "Incomplete match, missing : #{@undefined.join(" ")}" end @runner.call(*@data) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
funkr-0.0.23 | lib/funkr/adt/matcher.rb |
funkr-0.0.22 | lib/funkr/adt/matcher.rb |