Sha256: 13d8c0fb8d096bced7e276f28364b19b01909bfcd64339f43f7b524971baca55
Contents?: true
Size: 969 Bytes
Versions: 1
Compression:
Stored size: 969 Bytes
Contents
class Eventable::OpeningTime < ActiveRecord::Base set_table_name 'eventable_opening_times' belongs_to :opening_period, :class_name => 'Eventable::OpeningPeriod', :foreign_key => 'period_id' attr_accessible :day_of_week, :minutes_start, :minutes_end validates_inclusion_of :day_of_week, :in => 0..6 validates_inclusion_of :minutes_start, :minutes_end, :in => 0..1440 def self.day_selector (0..6).to_a.map {|n| [I18n.translate(:'date.day_names')[n],n]} end def self.time_selector (0..48).to_a.map do |n| [to_time_string(n*30), n*30] end end def after_initialize self.minutes_start ||= 540 self.minutes_end ||= 1080 end def open_at to_time_string(minutes_start) end def closed_at to_time_string(minutes_end) end private def self.to_time_string(m) return nil if m.blank? (Time.now.beginning_of_day + m.minutes).strftime "%H:%M" end delegate :to_time_string, :to => 'self.class' end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dcs-eventable-0.0.8 | app/models/eventable/opening_time.rb |