Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/time_of_day/ext/time.rb
Instance Method Summary collapse
- #compare_with_time_of_day(time) ⇒ Object (also: #<=>)
- #not_time_of_day ⇒ Object
- #not_time_of_day! ⇒ Object
- #time_of_day ⇒ Object
- #time_of_day! ⇒ Object
- #time_of_day? ⇒ Boolean
- #to_s_with_time_of_day(format = nil) ⇒ Object
Instance Method Details
#compare_with_time_of_day(time) ⇒ Object Also known as: <=>
29 30 31 32 33 34 35 36 37 |
# File 'lib/time_of_day/ext/time.rb', line 29 def compare_with_time_of_day(time) if self.time_of_day? && time.time_of_day? self.seconds_since_midnight <=> time.seconds_since_midnight else self.compare_without_time_of_day(time) end rescue self.compare_without_time_of_day(time) end |
#not_time_of_day ⇒ Object
20 21 22 |
# File 'lib/time_of_day/ext/time.rb', line 20 def not_time_of_day self.dup.not_time_of_day! end |
#not_time_of_day! ⇒ Object
24 25 26 27 |
# File 'lib/time_of_day/ext/time.rb', line 24 def not_time_of_day! @time_of_day = false self end |
#time_of_day ⇒ Object
11 12 13 |
# File 'lib/time_of_day/ext/time.rb', line 11 def time_of_day self.dup.time_of_day! end |
#time_of_day! ⇒ Object
15 16 17 18 |
# File 'lib/time_of_day/ext/time.rb', line 15 def time_of_day! @time_of_day = true self end |
#time_of_day? ⇒ Boolean
7 8 9 |
# File 'lib/time_of_day/ext/time.rb', line 7 def time_of_day? @time_of_day ||= false end |
#to_s_with_time_of_day(format = nil) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/time_of_day/ext/time.rb', line 41 def to_s_with_time_of_day(format=nil) unless format to_s_without_time_of_day(:time_utc) else to_s_without_time_of_day(format) end end |