I think that generate_note method is huge, you can split it with private methods and improve its legibility.