module RuboClaus::ClassMethods
Public Instance Methods
catch_all(_proc)
click to toggle source
# File lib/rubo_claus.rb, line 42 def catch_all(_proc) CatchAll.new(_proc) end
clause(args, function)
click to toggle source
# File lib/rubo_claus.rb, line 34 def clause(args, function) Clause.new(args, function) end
clauses(*klauses)
click to toggle source
# File lib/rubo_claus.rb, line 18 def clauses(*klauses) define_method(@function_name) do |*runtime_args| case matching_clause = find_matching_clause(klauses, runtime_args) when Clause execute(head_tail_handle(matching_clause.args, runtime_args), matching_clause.function) when PrivateClause raise NoPatternMatchError, "no pattern defined for: #{runtime_args}" unless @from_proc execute(head_tail_handle(matching_clause.args, runtime_args), matching_clause.function) when CatchAll execute(runtime_args, matching_clause.proc) else raise NoPatternMatchError, "no pattern defined for: #{runtime_args}" end end end
define_function(symbol, &block)
click to toggle source
# File lib/rubo_claus.rb, line 12 def define_function(symbol, &block) @function_name = symbol @from_proc = false block.call end
p_clause(args, function)
click to toggle source
# File lib/rubo_claus.rb, line 38 def p_clause(args, function) PrivateClause.new(args, function) end