Sha256: 68e16f7e8e185e4ba5f8db940b03ba2240128feda38e55d4e6c91fa10c4904a3

Contents?: true

Size: 578 Bytes

Versions: 3

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

module UKAcademicCalendar
  # Mixin included in Integer class
  module SuccSlashable
    # @param base [Integer]
    # @param slash_succ [Boolean] option specifying whether to leverage the "slash_succ" option
    # @return [String] string where self is concatenated with the value succeeding self, seperated by a forward slash
    # @example
    #   2023.to_s(slash_succ: true) #=> "2023/2024"
    def to_s(base = 10, slash_succ: false)
      if slash_succ
        "#{to_i}/#{to_i.succ}"
      else
        super(base)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uk_academic_calendar-1.1.0 lib/uk_academic_calendar/mixins/succ_slashable.rb
uk_academic_calendar-1.0.1 lib/uk_academic_calendar/mixins/succ_slashable.rb
uk_academic_calendar-1.0.0 lib/uk_academic_calendar/mixins/succ_slashable.rb