Class: AIXM::Schedule::DateTime
- Defined in:
- lib/aixm/schedule/date_time.rb
Overview
Datetimes suitable for schedules
This class combines AIXM::Schedule::Date
and AIXM::Schedule::Time
:
Instance Attribute Summary collapse
-
#date ⇒ AIXM::Schedule::Date
readonly
Date part.
-
#time ⇒ AIXM::Schedule::Time
readonly
Time part.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(date, time) ⇒ DateTime
constructor
Parse the given representation of date and time.
- #inspect ⇒ Object
-
#to_s ⇒ String
Human readable representation such as “2002-05-19 20:00”.
Constructor Details
#initialize(date, time) ⇒ DateTime
Parse the given representation of date and time.
32 33 34 35 36 |
# File 'lib/aixm/schedule/date_time.rb', line 32 def initialize(date, time) fail(ArgumentError, 'invalid date') unless date.instance_of? AIXM::Schedule::Date fail(ArgumentError, 'invalid time') unless time.instance_of? AIXM::Schedule::Time @date, @time = date, time end |
Instance Attribute Details
#date ⇒ AIXM::Schedule::Date (readonly)
Date part
21 22 23 |
# File 'lib/aixm/schedule/date_time.rb', line 21 def date @date end |
#time ⇒ AIXM::Schedule::Time (readonly)
Time part
26 27 28 |
# File 'lib/aixm/schedule/date_time.rb', line 26 def time @time end |
Instance Method Details
#hash ⇒ Object
50 51 52 |
# File 'lib/aixm/schedule/date_time.rb', line 50 def hash [@date.hash, @time.hash].hash end |
#inspect ⇒ Object
45 46 47 |
# File 'lib/aixm/schedule/date_time.rb', line 45 def inspect %Q(#<#{self.class} #{to_s}>) end |
#to_s ⇒ String
Human readable representation such as “2002-05-19 20:00”
41 42 43 |
# File 'lib/aixm/schedule/date_time.rb', line 41 def to_s [@date.to_s, @time.to_s].join(' ') end |