This repository has been archived on 2020-01-20. You can view files and clone it, but cannot push or open issues or pull requests.
evoresa/app/models/booking.rb
François Vaux 8d3dad9b8c base de l'application
* Affichage des ressources
* Affichage des évènements
* Affichage des réservations
* Partie d'administration protégée
2010-07-23 16:35:50 +02:00

19 lines
382 B
Ruby

class Booking < ActiveRecord::Base
UNIT = 100 / 24.0 / 4
belongs_to :event
def margin_for(date, offset)
quarter = [0, 15, 30, 45].index(((start_at.min/15.0).round * 15) % 60)
(start_at.hour * 4*UNIT) + (quarter * UNIT) - offset
end
def width_for(date)
(length/3600.0 * 4*UNIT) + ((length/60.0%60) * UNIT)
end
def length
end_at - start_at
end
end