Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/theampm.rb
Instance Method Summary collapse
-
#am ⇒ Object
A convenience for writing: 3.am or 1130.am.
- #pm ⇒ Object
- #to_time ⇒ Object
Instance Method Details
#am ⇒ Object
A convenience for writing: 3.am or 1130.am
6 7 8 |
# File 'lib/theampm.rb', line 6 def am Chronic.parse("#{self.to_s} am") end |
#pm ⇒ Object
10 11 12 |
# File 'lib/theampm.rb', line 10 def pm Chronic.parse("#{self.to_s} pm") end |
#to_time ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/theampm.rb', line 14 def to_time hour = self if hour < 12 || (hour >= 100 && hour < 1200) Chronic.parse("#{self.to_s} am") elsif hour >= 24 Chronic.parse("#{self.to_s}") else Chronic.parse("#{self.to_s} pm") end end |