```ruby
require "metamorpher/builders/ast"

module Metamorpher
  module Builders
    module Ruby
      class UppercaseConstantRewriter
        include Metamorpher::Rewriter
        include Metamorpher::Builders::AST

        def pattern
          builder.const(
            builder.literal!(nil),
            builder.VARIABLE_TO_BE { |v| v.name && v.name.to_s[/^[A-Z_]*$/] }
          )
        end

        def replacement
          builder.derivation!(:variable_to_be) do |variable_to_be, builder|
            name = variable_to_be.name.to_s

            if name.end_with?("_")
              builder.greedy_variable! name.chomp("_").downcase.to_sym
            else
              builder.variable! name.downcase.to_sym
            end
          end
        end
      end
    end
  end
end
```

Reduce duplication in Ruby builder code.
user
```ruby
require "metamorpher/builders/ast"
require "metamorpher/builders/ruby/uppercase_rewriter"

module Metamorpher
  module Builders
    module Ruby
      class UppercaseConstantRewriter < UppercaseRewriter
        include Metamorpher::Rewriter
        include Metamorpher::Builders::AST

        def pattern
          builder.const(builder.literal!(nil), super)
        end
      end
    end
  end
end
```
assistant