Class: Rx::Check::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/rx/check/result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, ok, timing, error) ⇒ Result

Returns a new instance of Result.



22
23
24
25
26
27
# File 'lib/rx/check/result.rb', line 22

def initialize(name, ok, timing, error)
  @name = name
  @ok = ok
  @timing = timing
  @error = error
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



20
21
22
# File 'lib/rx/check/result.rb', line 20

def error
  @error
end

#nameObject (readonly)

Returns the value of attribute name.



20
21
22
# File 'lib/rx/check/result.rb', line 20

def name
  @name
end

#timingObject (readonly)

Returns the value of attribute timing.



20
21
22
# File 'lib/rx/check/result.rb', line 20

def timing
  @timing
end

Class Method Details

.from(check_name) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rx/check/result.rb', line 4

def self.from(check_name)
  start_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  err = nil
  result = false

  begin
    result = yield
  rescue StandardError => ex
    err = ex
  end

  end_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)

  Result.new(check_name, result, ((end_at - start_at) * 1000).round(2), err)
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rx/check/result.rb', line 29

def ok?
  @ok
end