<commit_before>require "timecoder/version"

SECONDS_IN_MINUTE = 60
SECONDS_IN_HOUR = 60*60

module Timecoder
  def self.timecode_to_seconds(timecode)
    timecode_split = timecode.split(":")
    raise if timecode_split.length != 3

    hours = timecode.split(":")[0].to_i
    minutes = timecode.split(":")[1].to_i
    seconds = timecode.split(":")[2].to_i

    seconds + minutes_to_seconds(minutes) + hours_to_seconds(hours)
  end

  def self.seconds_to_timecode(total_seconds)
    raise if !total_seconds.class.eql?(Fixnum)

    if total_seconds < SECONDS_IN_MINUTE
      timecode_str(0, 0, total_seconds)
    elsif total_seconds < SECONDS_IN_HOUR
      minutes = seconds_to_minutes(total_seconds)
      seconds = total_seconds - minutes_to_seconds(minutes)

      timecode_str(0, minutes, seconds)
    else
      hours = seconds_to_hours(total_seconds)
      total_seconds -= hours_to_seconds(hours)
      minutes = seconds_to_minutes(total_seconds)
      total_seconds -= minutes_to_seconds(minutes)
      seconds = total_seconds
      
      timecode_str(hours, minutes, seconds)
    end<commit_msg>more refactoring<commit_after>require "timecoder/version"

SECONDS_IN_MINUTE = 60
SECONDS_IN_HOUR = 60*60

module Timecoder
  def self.timecode_to_seconds(timecode)
    timecode_split = timecode.split(":")
    raise if timecode_split.length != 3

    hours = timecode.split(":")[0].to_i
    minutes = timecode.split(":")[1].to_i
    seconds = timecode.split(":")[2].to_i

    seconds + minutes_to_seconds(minutes) + hours_to_seconds(hours)
  end

  def self.seconds_to_timecode(total_seconds)
    raise if !total_seconds.class.eql?(Fixnum)

    hours = seconds_to_hours(total_seconds)
    total_seconds -= hours_to_seconds(hours)
    minutes = seconds_to_minutes(total_seconds)
    total_seconds -= minutes_to_seconds(minutes)
    seconds = total_seconds
    
    timecode_str(hours, minutes, seconds)
{'fraction_non_alphanumeric': 0.09926470588235294, 'fraction_numerical': 0.01207983193277311, 'mean_word_length': 4.233516483516484, 'pattern_counts': {'":': 8, '<': 5, '<?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': '1598980', 'n_tokens_mistral': 685, 'n_tokens_neox': 648, 'n_words': 107}