There is URI library in ruby which can return you scheme to check