<commit_before>require_relative 'month'

class Year
  attr_reader :year

  def initialize(year)
    @year = year
  end

  def leap?
    if (@year % 4 == 0)
      if (@year % 100 == 0) and (@year % 400 != 0)
        return 28
      else
        return 29
      end
    else
      return 28
    end
  end

  def to_s
    year_output = ""
    year_arr    = []
    12.times {|month| year_arr.push(Month.new((month + 1), @year)) }
    year_output << "#{year.to_s.center(63).rstrip}\n\n"
    year_arr.each_slice(3) do |month|
      year_output << <<EOS
#{month[0].name.center(20)}  #{month[1].name.center(20)}  #{month[2].name.center(20).rstrip}
EOS
      line_num = 0
      while line_num < 7
        month.each do |single|
          if !single.print_days.lines[line_num].nil?
            if single.print_days.lines[line_num] == single.print_days.lines.last
              if single != month.last
                year_output << "#{single.print_days.lines[line_num].chomp.ljust(22)}"
              else
                  year_output << "#{single.print_days.lines[line_num].chomp.ljust(22).rstrip}\n"
              end
            else
              if single != month.last
                year_output << "#{single.print_days.lines[line_num].chomp.ljust(22)}"
              else
                year_output << "#{single.print_days.lines[line_num].chomp.ljust(22).rstrip}\n"
              end
            end
          else
            if single != month.last
              year_output << "#{(" " * 22).chomp.ljust(22)}"
            else
              year_output << "\n"
            end
          end
        end
        line_num += 1
      end
    end
    year_output
  end
end<commit_msg>year to_s refactor<commit_after>require_relative 'month'

class Year
  attr_reader :year

  def initialize(year)
    @year = year
  end

  def leap?
    if (@year % 4 == 0)
      if (@year % 100 == 0) and (@year % 400 != 0)
        return 28
      else
        return 29
      end
    else
      return 28
    end
  end

  def to_s
    year_output = ""
    year_arr    = []
    12.times {|month| year_arr.push(Month.new((month + 1), @year)) }
    year_output << "#{year.to_s.center(63).rstrip}\n\n"
    year_arr.each_slice(3) do |month_row|
      year_output << <<EOS
#{month_row[0].name.center(20)}  #{month_row[1].name.center(20)}  #{month_row[2].name.center(20).rstrip}
EOS
      7.times do |n|
        month_row.each do |month|
          if !month.print_days.lines[n].nil?
              if month != month_row.last
                year_output << "#{month.print_days.lines[n].chomp.ljust(22)}"
              else
                year_output << "#{month.print_days.lines[n].rstrip}\n"
              end
          else
            if month != month_row.last
              year_output << "#{(" " * 22).chomp.ljust(22)}"
            else
              year_output << "\n"
            end
          end
        end
      end
    end
    year_output
  end
end
{'fraction_non_alphanumeric': 0.132448076268301, 'fraction_numerical': 0.028600612870275793, 'mean_word_length': 1.7128347183748847, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1139224', 'n_tokens_mistral': 1042, 'n_tokens_neox': 977, 'n_words': 199}