Class: JsonStatham::Requests::Observer

Inherits:
Base
  • Object
show all
Defined in:
lib/json_statham/requests/observer.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#parser

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#base_path, call, #file_path, #folder?, #folder_path, #initialize, #schema_name, #splitted_name

Constructor Details

This class inherits a constructor from JsonStatham::Requests::Base

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/json_statham/requests/observer.rb', line 6

def data
  @data
end

#durationObject (readonly)

Returns the value of attribute duration.



6
7
8
# File 'lib/json_statham/requests/observer.rb', line 6

def duration
  @duration
end

#endingObject (readonly)

Returns the value of attribute ending.



6
7
8
# File 'lib/json_statham/requests/observer.rb', line 6

def ending
  @ending
end

#startingObject (readonly)

Returns the value of attribute starting.



6
7
8
# File 'lib/json_statham/requests/observer.rb', line 6

def starting
  @starting
end

Class Method Details

.clock_gettimeObject



8
9
10
# File 'lib/json_statham/requests/observer.rb', line 8

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

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
# File 'lib/json_statham/requests/observer.rb', line 12

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

  self
end

#clock_gettimeObject



21
22
23
# File 'lib/json_statham/requests/observer.rb', line 21

def clock_gettime
  self.class.clock_gettime
end