[Fix #367] Check RPMTAG class before cast

Support number and string TAG types from librpm.