<commit_before>module Poms
  class ScheduleEvent < Poms::Builder::NestedOpenStruct

    def initialize hash
      @hash = hash
      set_start_and_end_times
      super @hash
    end

    private

    def set_start_and_end_times
      set_starts_at
      set_ends_at
    end

    def set_starts_at
      @hash[:starts_at] = case @hash[:start]
        when String, Integer
          Time.at @hash[:start] / 1000
        when Time
          @hash[:start]
        end
    end

    def set_ends_at
      @hash['ends_at'] = @hash[:starts_at] + (@hash[:duration].to_i / 1000).seconds
    end

  end
end
<commit_msg>give ScheduleEvent a #duration<commit_after>module Poms
  class ScheduleEvent < Poms::Builder::NestedOpenStruct

    def initialize hash
      @hash = hash
      set_start_and_end_times
      super @hash
    end

    private

    def set_start_and_end_times
      set_starts_at
      set_ends_at
    end

    def set_starts_at
      @hash[:starts_at] = case @hash[:start]
        when String, Integer
          Time.at @hash[:start] / 1000
        when Time
          @hash[:start]
        end
    end

    def set_ends_at
      @hash['ends_at'] = @hash[:starts_at] + duration
    end

    def duration
      (@hash[:duration].to_i / 1000).seconds
    end

  end
end

{'fraction_non_alphanumeric': 0.08072100313479624, 'fraction_numerical': 0.012539184952978056, 'mean_word_length': 2.1845386533665834, 'pattern_counts': {'":': 0, '<': 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': '2853653', 'n_tokens_mistral': 442, 'n_tokens_neox': 411, 'n_words': 97}