Refactor post.rb to remove duplication

Closes #26