instance method serialize

Ruby on Rails 5.0.7.2

Since v5.0.7.2 Last seen in v5.0.7.2

Signature

serialize()

Builds and returns output string.

Source
# File activesupport/lib/active_support/duration/iso8601_serializer.rb, line 14
      def serialize
        output = 'P'
        parts, sign = normalize
        output << "#{parts[:years]}Y"   if parts.key?(:years)
        output << "#{parts[:months]}M"  if parts.key?(:months)
        output << "#{parts[:weeks]}W"   if parts.key?(:weeks)
        output << "#{parts[:days]}D"    if parts.key?(:days)
        time = ''
        time << "#{parts[:hours]}H"     if parts.key?(:hours)
        time << "#{parts[:minutes]}M"   if parts.key?(:minutes)
        if parts.key?(:seconds)
          time << "#{sprintf(@precision ? "%0.0#{@precision}f" : '%g', parts[:seconds])}S"
        end
        output << "T#{time}"  if time.present?
        "#{sign}#{output}"
      end

Defined in activesupport/lib/active_support/duration/iso8601_serializer.rb line 14 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::Duration::ISO8601Serializer

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close