<commit_before># SingleTimes, RecurringTimes etc. are converted to TimeChunks for calculations and display
class TimeChunk
  attr_accessor :starts, :ends, :time_type, :parent, :first_half_day, :second_half_day

  def initialize(opts)
    if opts[:range]
      self.starts = opts[:range].min
      self.ends = opts[:range].max
    else
      self.starts = opts[:starts]
      self.ends = opts[:ends]
    end
    self.parent = opts[:parent]
    self.time_type = opts[:time_type]
    self.first_half_day = opts[:first_half_day]
    self.second_half_day = opts[:second_half_day]
  end

  def range
    (starts..ends)
  end

  def duration
    if time_type.calculate_work_hours_only?
      range.duration.to_f / 24.hours * UberZeit::Config[:work_per_day]
    else
      range.duration
    end
  end

  def whole_day?
    first_half_day && second_half_day
  end
end<commit_msg>change time_chunk to delegate the boolean check to the parent<commit_after># SingleTimes, RecurringTimes etc. are converted to TimeChunks for calculations and display
class TimeChunk
  attr_accessor :starts, :ends, :time_type, :parent

  def initialize(opts)
    if opts[:range]
      self.starts = opts[:range].min
      self.ends = opts[:range].max
    else
      self.starts = opts[:starts]
      self.ends = opts[:ends]
    end
    self.parent = opts[:parent]
    self.time_type = opts[:time_type]
  end

  def range
    (starts..ends)
  end

  def duration
    if time_type.calculate_work_hours_only?
      range.duration.to_f / 24.hours * UberZeit::Config[:work_per_day]
    else
      range.duration
    end
  end

  def first_half_day?
    @first_half_day ||= half_day_specific? && parent.first_half_day?
  end

  def second_half_day?
    @second_half_day ||= half_day_specific? && parent.second_half_day?
  end

  def whole_day?
    @whole_day ||= half_day_specific? && parent.whole_day?
  end

  def half_day_specific?
    @half_day_specific ||= parent.respond_to?(:whole_day?)
  end
end
{'fraction_non_alphanumeric': 0.0975609756097561, 'fraction_numerical': 0.0020325203252032522, 'mean_word_length': 3.4049217002237135, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2192512', 'n_tokens_mistral': 691, 'n_tokens_neox': 664, 'n_words': 150}