File: active_support/core_ext/float/time.rb

Overview
Module Structure
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: ActiveSupport#1
  module: CoreExtensions#2
  module: Float#3
  module: Time#4
has properties
method: years #6
method: months #10
method: months_without_deprecation #15
alias: month months #18
method: years_without_deprecation #20
alias: year years #23

Code

   1  module ActiveSupport #:nodoc:
   2    module CoreExtensions #:nodoc:
   3      module Float #:nodoc:
   4        module Time
   5          # Deprication helper methods not available as core_ext is loaded first.
   6          def years
   7            ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:years, "Fractional years are not respected. Convert value to integer before calling #years."), caller)
   8            years_without_deprecation
   9          end
  10          def months
  11            ::ActiveSupport::Deprecation.warn(self.class.deprecated_method_warning(:months, "Fractional months are not respected. Convert value to integer before calling #months."), caller)
  12            months_without_deprecation
  13          end
  14 
  15          def months_without_deprecation
  16            ActiveSupport::Duration.new(self * 30.days, [[:months, self]])
  17          end
  18          alias :month :months
  19        
  20          def years_without_deprecation
  21            ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]])
  22          end
  23          alias :year :years
  24        end
  25      end
  26    end
  27  en