Class: Spina::Admin::Conferences::TimePart
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Spina::Admin::Conferences::TimePart
- Defined in:
- app/models/spina/admin/conferences/time_part.rb
Overview
Time parts.
Instance Method Summary collapse
-
#date ⇒ Date?
The date of the time part.
-
#date=(date) ⇒ void
Sets the date of the time part.
-
#time ⇒ ActiveSupport::TimeWithZone?
The time of the time part.
-
#time=(time) ⇒ void
Sets the start time of the time part.
Instance Method Details
#date ⇒ Date?
Returns the date of the time part. Nil if the time part has no date and time.
14 15 16 17 18 |
# File 'app/models/spina/admin/conferences/time_part.rb', line 14 def date return if content.blank? content.to_date end |
#date=(date) ⇒ void
This method returns an undefined value.
Sets the date of the time part.
23 24 25 26 27 28 29 30 |
# File 'app/models/spina/admin/conferences/time_part.rb', line 23 def date=(date) if date.blank? || date.to_date.blank? self.content = nil return end self.content = date.to_date + (content.try(:seconds_since_midnight) || 0).seconds end |
#time ⇒ ActiveSupport::TimeWithZone?
Returns the time of the time part. Nil if the time part has no date and time.
33 34 35 36 37 |
# File 'app/models/spina/admin/conferences/time_part.rb', line 33 def time return if content.blank? content end |
#time=(time) ⇒ void
This method returns an undefined value.
Sets the start time of the time part.
42 43 44 45 46 47 48 49 |
# File 'app/models/spina/admin/conferences/time_part.rb', line 42 def time=(time) if time.blank? self.content = nil return end self.content = Time.parse(time, date).to_datetime.in_time_zone end |