Sha256: 8986d082e2f05ecc1c0037dc4af2b9a857ec3ff66bd415e1be4d9a821e6babfc

Contents?: true

Size: 523 Bytes

Versions: 3

Compression:

Stored size: 523 Bytes

Contents

# frozen_string_literal: true

module JsonStatham
  module Requests
    class Observer < Base
      attr_reader :starting, :ending, :data, :duration

      def self.clock_gettime
        Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
      end

      def call
        @starting = clock_gettime
        @data     = block.call
        @ending   = clock_gettime
        @duration = ending - starting

        self
      end

      def clock_gettime
        self.class.clock_gettime
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json_statham-0.1.3 lib/json_statham/requests/observer.rb
json_statham-0.1.2 lib/json_statham/requests/observer.rb
json_statham-0.1.0 lib/json_statham/requests/observer.rb