Method: ActiveSupport::Duration#initialize

Defined in:
activesupport/lib/active_support/duration.rb

#initialize(value, parts, variable = nil) ⇒ Duration

:nodoc:



226
227
228
229
230
231
232
233
234
235
# File 'activesupport/lib/active_support/duration.rb', line 226

def initialize(value, parts, variable = nil) # :nodoc:
  @value, @parts = value, parts
  @parts.reject! { |k, v| v.zero? } unless value == 0
  @parts.freeze
  @variable = variable

  if @variable.nil?
    @variable = @parts.any? { |part, _| VARIABLE_PARTS.include?(part) }
  end
end