Module: ClockAngleCalculator
- Defined in:
- lib/clock_angle_calculator.rb,
lib/clock_angle_calculator/version.rb
Constant Summary collapse
- VERSION =
"1.0.3"
Class Method Summary collapse
-
.calculate_angle(hour, minute) ⇒ Object
given an hour and minute, model the time on an analog clock return the angle between the hour and minute hands on the clock.
-
.calculate_angle_datetime(datetime) ⇒ Object
given a datetime, model the time on an analog clock return the angle between the hour and minute hands on the clock.
Class Method Details
.calculate_angle(hour, minute) ⇒ Object
given an hour and minute, model the time on an analog clock return the angle between the hour and minute hands on the clock
19 20 21 |
# File 'lib/clock_angle_calculator.rb', line 19 def self.calculate_angle(hour, minute) return calculate_angle_helper(hour, minute) end |
.calculate_angle_datetime(datetime) ⇒ Object
given a datetime, model the time on an analog clock return the angle between the hour and minute hands on the clock
7 8 9 10 11 12 13 14 15 |
# File 'lib/clock_angle_calculator.rb', line 7 def self.calculate_angle_datetime(datetime) if datetime.is_a?(DateTime) || datetime.is_a?(Time) || datetime.is_a?(Date) hour = (datetime.strftime("%H")).to_f % 12 minute = datetime.strftime("%M").to_f return calculate_angle_helper(hour, minute) else return nil end end |