<commit_before>module Moon
  class Transition
    ### class variables
    @@id = 0

    ### instance attributes
    attr_accessor :key
    attr_accessor :easer
    attr_accessor :src
    attr_accessor :dest
    attr_reader :id
    attr_reader :time
    attr_reader :duration

    ###
    # initialize(src, dest, duration) { |value| transition_callback }
    # @param [Object] src
    # @param [Object] dest
    # @param [Float] duration  in seconds
    # @return [Void]
    ###
    def initialize(src, dest, duration, easer=Easing::Linear, &block)
      @id = @@id += 1
      @key = nil
      @src = src
      @dest = dest
      @time = 0.0
      @duration = TimeUtil.to_duration(duration)
      @easer = easer
      @callback = block
    end

    ###
    # @return [Boolean]
    ###
    def done?
      @time >= @duration
    end

    ###
    # @return [Void]
    ###
    def refresh
      @callback.call(@src + (@dest - @src) * @easer.call(@time / @duration))
    end

    ###
    # @param [Float] delta
    # @return [Void]
    ###
    def update(delta)
      return if done?
      @time += delta
      @time = @duration if @time > @duration
      refresh
    end

    ###
    # @return [Void]
    ###
    def finish
      @time = @duration
      refresh
    end<commit_msg>std: Transition is now a Scheduler TimedProcess job<commit_after>require 'scheduler/jobs/timed_process'

module Moon
  class Transition < Scheduler::Jobs::TimedProcess
    ### instance attributes
    attr_accessor :easer

    # @param [Object] src
    # @param [Object] dest
    # @param [String, Numeric] duration
    # @param [#call] easer
    def initialize(src, dest, duration, easer = Easing::Linear, &block)
      super(duration, &block)
      setup(src, dest, easer)
    end

    # @param [Object] src
    # @param [Object] dest
    # @param [#call] easer
    # @return [self]
    def setup(src, dest, easer = Easing::Linear)
      @src = src
      @dest = dest
      @easer = easer
      self
    end

    # @param [Float] delta
    # @return [void]
    def update_ease(delta)
      time_inv = (@duration - @time).clamp(0, @duration)
      @callback.call(@src + (@dest - @src) * @easer.call(time_inv / @duration))
    end

    # @param [Float] delta
    # @return [void]
    def update_job_step(delta)
      update_ease delta
    end
{'fraction_non_alphanumeric': 0.12899050905953408, 'fraction_numerical': 0.0021570319240724763, 'mean_word_length': 2.3128571428571427, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '1075735', 'n_tokens_mistral': 770, 'n_tokens_neox': 752, 'n_words': 204}