<commit_before>module Tod
  class TimeOfDay
    include Comparable

    attr_reader :hour, :minute, :second, :second_of_day
    alias_method :min, :minute
    alias_method :sec, :second
    alias_method :to_i, :second_of_day

    PARSE_24H_REGEX = /
      \A
      ([01]?\d|2[0-3])
      :?
      ([0-5]\d)?
      :?
      ([0-5]\d)?
      \z
    /x

    PARSE_12H_REGEX = /
      \A
      (0?\d|1[0-2])
      :?
      ([0-5]\d)?
      :?
      ([0-5]\d)?
      \s*
      ([ap])
      \.?
      \s*
      m?
      \.?
      \z
    /x

    WORDS = {
      "noon" => "12pm",
      "midnight" => "12am"
    }

    NUM_SECONDS_IN_DAY = 86400
    NUM_SECONDS_IN_HOUR = 3600
    NUM_SECONDS_IN_MINUTE = 60

    def initialize(h, m=0, s=0)
      @hour = Integer(h)
      @minute = Integer(m)
      @second = Integer(s)

      raise ArgumentError, "hour must be between 0 and 23" unless (0..23).include?(@hour)
      raise ArgumentError, "minute must be between 0 and 59" unless (0..59).include?(@minute)
      raise ArgumentError, "second must be between 0 and 59" unless (0..59).include?(@second)

      @second_of_day = @hour * 60 * 60 + @minute * 60 + @second

      freeze # TimeOfDay instances are value objects
    end

    def <=>(other)
      return unless other.respond_to?(:second_of_day)
      @second_of_day <=> other.second_of_day
    end

    # Formats identically to Time#strftime
    def strftime(format_string)
      Time.local(2000,1,1, @hour, @minute, @second).strftime(format_string)
    end

    def to_s
      strftime "%H:%M:%S"
    end

    # Return a new TimeOfDay num_seconds greater than self. It will wrap around
    # at midnight.
    def +(num_seconds)
      TimeOfDay.from_second_of_day @second_of_day + num_seconds
    end

    # Return a new TimeOfDay num_seconds less than self. It will wrap around
    # at midnight.
    def -(num_seconds)
      TimeOfDay.from_second_of_day @second_of_day - num_seconds
    end
<commit_msg>Adds codes for activate Addition and Subtraction operators with right side Tod Object<commit_after>module Tod
  class TimeOfDay
    include Comparable

    attr_reader :hour, :minute, :second, :second_of_day
    alias_method :min, :minute
    alias_method :sec, :second
    alias_method :to_i, :second_of_day

    PARSE_24H_REGEX = /
      \A
      ([01]?\d|2[0-3])
      :?
      ([0-5]\d)?
      :?
      ([0-5]\d)?
      \z
    /x

    PARSE_12H_REGEX = /
      \A
      (0?\d|1[0-2])
      :?
      ([0-5]\d)?
      :?
      ([0-5]\d)?
      \s*
      ([ap])
      \.?
      \s*
      m?
      \.?
      \z
    /x

    WORDS = {
      "noon" => "12pm",
      "midnight" => "12am"
    }

    NUM_SECONDS_IN_DAY = 86400
    NUM_SECONDS_IN_HOUR = 3600
    NUM_SECONDS_IN_MINUTE = 60

    def initialize(h, m=0, s=0)
      @hour = Integer(h)
      @minute = Integer(m)
      @second = Integer(s)

      raise ArgumentError, "hour must be between 0 and 23" unless (0..23).include?(@hour)
      raise ArgumentError, "minute must be between 0 and 59" unless (0..59).include?(@minute)
      raise ArgumentError, "second must be between 0 and 59" unless (0..59).include?(@second)

      @second_of_day = @hour * 60 * 60 + @minute * 60 + @second

      freeze # TimeOfDay instances are value objects
    end

    def <=>(other)
      return unless other.respond_to?(:second_of_day)
      @second_of_day <=> other.second_of_day
    end

    # Formats identically to Time#strftime
    def strftime(format_string)
      Time.local(2000,1,1, @hour, @minute, @second).strftime(format_string)
    end

    def to_s
      strftime "%H:%M:%S"
    end

    # Return a new TimeOfDay num_seconds greater than self. It will wrap around
    # at midnight.
    def +(other)
      if other.instance_of?(TimeOfDay)
        TimeOfDay.from_second_of_day @second_of_day + other.second_of_day
      else
        TimeOfDay.from_second_of_day @second_of_day + other
      end
    end

    # Return a new TimeOfDay num_seconds less than self. It will wrap around
    # at midnight.
    def -(other)
      if other.instance_of?(TimeOfDay)
        TimeOfDay.from_second_of_day @second_of_day - other.second_of_day
      else
        TimeOfDay.from_second_of_day @second_of_day - other
      end
    end

{'fraction_non_alphanumeric': 0.11837121212121213, 'fraction_numerical': 0.032196969696969696, 'mean_word_length': 2.2251908396946565, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '5411435', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1507, 'n_words': 366}