Class: Betterp::TimedBlock
- Inherits:
-
Object
- Object
- Betterp::TimedBlock
- Defined in:
- lib/betterp/timed_block.rb
Overview
Executes a block and returns the block result and duration.
Instance Method Summary collapse
-
#initialize(block:) ⇒ TimedBlock
constructor
A new instance of TimedBlock.
- #result ⇒ Object
Constructor Details
#initialize(block:) ⇒ TimedBlock
Returns a new instance of TimedBlock.
6 7 8 |
# File 'lib/betterp/timed_block.rb', line 6 def initialize(block:) @block = block end |
Instance Method Details
#result ⇒ Object
10 11 12 13 14 |
# File 'lib/betterp/timed_block.rb', line 10 def result start = Time.now.utc block_result = block.call [block_result, Time.now.utc - start] end |