module RuboClaus
Constants
- CatchAll
- Clause
- PrivateClause
- VERSION
Public Class Methods
included(klass)
click to toggle source
# File lib/rubo_claus.rb, line 70 def self.included(klass) klass.extend ClassMethods end
Private Instance Methods
execute(args, proc)
click to toggle source
# File lib/rubo_claus.rb, line 47 def execute(args, proc) @from_proc = true method = instance_exec *args, &proc @from_proc = false method end
find_matching_clause(klauses, runtime_args)
click to toggle source
# File lib/rubo_claus.rb, line 54 def find_matching_clause(klauses, runtime_args) clause = klauses.find { |pattern| match?(pattern, runtime_args) } return clause if [Clause, PrivateClause, CatchAll].include?(clause.class) end
head_tail_handle(lhs, rhs)
click to toggle source
# File lib/rubo_claus.rb, line 59 def head_tail_handle(lhs, rhs) lhs.each_with_index.flat_map do |arg, index| if arg.is_a?(Array) && arg.include?(:tail) number_of_heads = lhs[index][0..-2].size rhs[index][0..(number_of_heads - 1)] + [rhs[index][number_of_heads..-1]] else [rhs[index]] end end end