Skip to content

Instantly share code, notes, and snippets.

@VoronoyAlexandr
Created July 1, 2015 13:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VoronoyAlexandr/de2ed22fb93161b0d55a to your computer and use it in GitHub Desktop.
Save VoronoyAlexandr/de2ed22fb93161b0d55a to your computer and use it in GitHub Desktop.
def email_notification
<<-TEXT
Hello, #{email_notification_params[:reader_name]}
You should return a book #{email_notification_params[:book_title]} authored by "#{email_notification_params[:book_author]}" in #{email_notification_params[:time_left]} hours.
Otherwise you will be charged $#{email_notification_params[:penalty_per_hour]} per hour.
TEXT
end
def email_notification_params
{
reader_name: reader_with_book.name,
book_title: reader_with_book.book.title,
book_author: reader_with_book.book.author.name,
time_left: ((issue_datetime.to_i - Time.now.to_i) / 3600),
penalty_per_hour: sprintf("%.2f", ((reader_with_book.book.penalty_per_hour) / 100)).to_f
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment