Class: Reprise::TimeOfDay Private

Inherits:
Object
  • Object
show all
Defined in:
lib/reprise/time_of_day.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: InvalidHashError, RangeError, UnsupportedTypeError

Constant Summary collapse

DEFAULT_TIME_OF_DAY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{ hour: 0, minute: 0, second: 0 }.freeze
TIME_OF_DAY_ATTRIBUTES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

DEFAULT_TIME_OF_DAY.keys.freeze

Instance Method Summary collapse

Constructor Details

#initialize(time_of_day) ⇒ TimeOfDay

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TimeOfDay.

Examples:

{ hour: 1, minute: 30, second: 15 }

Parameters:

  • time_of_day (Time, Hash)

    Accepts either a local time value from which the hour, minute, and second should be derived, or a hash containing at least one of hour, minute, or second.

Options Hash (time_of_day):

  • :hour, (Integer)

    >= 0 && <= 23

  • :minute, (Integer)

    >= 0 && <= 59

  • :second, (Integer)

    >= 0 && <= 59

Raises:



29
30
31
32
33
34
# File 'lib/reprise/time_of_day.rb', line 29

def initialize(time_of_day)
  return initialize_from_hash(time_of_day) if time_of_day.is_a?(Hash)
  return initialize_from_time(time_of_day) if time_of_day.is_a?(Time)

  raise UnsupportedTypeError, "#{time_of_day.class} is not a supported type"
end

Instance Method Details

#to_hHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Examples:

{ hour: 1, minute: 30, second: 15 }

Returns:

  • (Hash)


39
40
41
42
43
44
45
# File 'lib/reprise/time_of_day.rb', line 39

def to_h
  {
    hour:,
    minute:,
    second:
  }
end