Module: UKAcademicCalendar::SuccSlashable

Included in:
Integer
Defined in:
lib/uk_academic_calendar/mixins/succ_slashable.rb

Overview

Mixin included in Integer class

Instance Method Summary collapse

Instance Method Details

#to_s(base = 10, slash_succ: false) ⇒ String

Returns string where self is concatenated with the value succeeding self, seperated by a forward slash.

Examples:

2023.to_s(slash_succ: true) #=> "2023/2024"

Parameters:

  • base (Integer) (defaults to: 10)
  • slash_succ (Boolean) (defaults to: false)

    option specifying whether to leverage the “slash_succ” option

Returns:

  • (String)

    string where self is concatenated with the value succeeding self, seperated by a forward slash



11
12
13
14
15
16
17
# File 'lib/uk_academic_calendar/mixins/succ_slashable.rb', line 11

def to_s(base = 10, slash_succ: false)
  if slash_succ
    "#{to_i}/#{to_i.succ}"
  else
    super(base)
  end
end