Ruby word counter from the 'pickaxe' book (1.9 edition 3)