Your best bet would probably be to try to parse each section in to some sort of datastructure, probably an array of hashes or something similar. Everytime you hit that "header section", start a new hash, then store the various class data. Then you can search through this array, find the section you want and have other data already there, ready to be used.