Sha256: 9d64d7b14288248a119caefe8cee7bc5ed2eb355cbb29e2c62ef4705f4ab7fad
Contents?: true
Size: 817 Bytes
Versions: 8
Compression:
Stored size: 817 Bytes
Contents
require "metamorpher/terms/variable" module Metamorpher module Builders module AST class GreedyVariableBuilder def greedy_variable!(name, &block) if block Terms::Variable.new(name: name, greedy?: true, condition: block) else Terms::Variable.new(name: name, greedy?: true) end end def shorthand?(method, *_arguments, &_block) !method[/\p{Lower}/] && method.to_s.end_with?("_") end def method_missing(method, *arguments, &block) if shorthand?(method, *arguments, &block) greedy_variable!(method.to_s.chomp("_").downcase.to_sym, *arguments, &block) else super.method_missing(method, *arguments, &block) end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems