Switch from shell to Ruby
Use one regexp instead of string manipulation to extract data
Return object instead of outputting
Add spec file
Trim trailing whitespace from class names