Add missing bracket

"#@instance_variable" is confusing style.
Use %r

This makes regular expression readable, because we do not need escape
slashes.
Use Array#include? instead of Array#index

It represents the intent of the code.
Use unless instead of if not

Follow our coding standard.
Split guard to simplify code
Use "..." instead of '...'
Simplify code

Original code is too complex.
Do not use unless ... else ... end

Follow our coding standard.
Use meaningful name
Add missing space for emacs syntax highlight
Align
Use Array#each instead of while loop to simplify code
Fix indent
Use if-else instead of unless-else

Follow our coding standard.
Use guard to simplify code
Use case-when to simplify code
Use case-when to simplify code
Add guard for reference_type
Use dynamic method call instead of static method call
Use "..." instead of '...'