Sha256: d7b41d92c9f81704faac1a28e808c8f698bee8b13eb434dc11fb2bf131984695

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 Bytes

Contents

module Fasten
  module Support
    module State
      attr_accessor :error, :ini, :fin, :dif, :runner
      attr_writer :state

      def state
        @state || :IDLE
      end

      def running?
        state == :RUNNING
      end

      def idle?
        state == :IDLE
      end

      def pausing?
        state == :PAUSING
      end

      def paused?
        state == :PAUSED
      end

      def quitting?
        state == :QUITTING
      end

      def last
        return @last if defined? @last

        return {} unless @runner

        @last = runner.stats_last(self)
      end

      def last_avg
        @last_avg ||= last['avg']&.to_f
      end

      def last_err
        @last_err ||= last['err']&.to_f
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fasten-0.12.6 lib/fasten/support/state.rb