Method: TimeCalc::Value#merge

Defined in:
lib/time_calc/value.rb

#merge(**attrs) ⇒ Value

Produces new value with some components of underlying time/date replaced.

Examples:

TimeCalc.from(Date.parse('2018-06-01')).merge(year: 1983)
# => #<TimeCalc::Value(1983-06-01)>

Parameters:

  • attrs (Hash<Symbol => Integer>)

Returns:



89
90
91
92
# File 'lib/time_calc/value.rb', line 89

def merge(**attrs)
  class_name = CLASS_NAME.bind(internal.class).call.tr(':', '_')
  Value.new(Types.public_send("merge_#{class_name.downcase}", internal, **attrs))
end