Class: Trip::Fiber
- Inherits:
-
Object
- Object
- Trip::Fiber
- Defined in:
- lib/trip/fiber.rb
Overview
The Trip::Fiber class is responsible for creating and controlling an instance of Ruby’s Fiber class that will run and trace a piece of Ruby code. This class is not intended to be used directly.
Instance Method Summary collapse
-
#initialize(trip) ⇒ Trip::Fiber
constructor
Returns an instance of Trip::Fiber.
-
#create ⇒ Trip::Fiber
Creates a fiber.
-
#resume ⇒ Trip::Event?
Resumes a fiber.
Constructor Details
#initialize(trip) ⇒ Trip::Fiber
Returns an instance of Trip::Fiber.
21 22 23 24 25 |
# File 'lib/trip/fiber.rb', line 21 def initialize(trip) @trip = trip @tracer = nil @fiber = nil end |
Instance Method Details
#create ⇒ Trip::Fiber
Creates a fiber.
32 33 34 35 36 37 38 39 40 |
# File 'lib/trip/fiber.rb', line 32 def create @fiber = Fiber.new do @tracer = TracePoint.new(*events, &method(:receive_event)) @tracer.enable @trip.callable.call @tracer.disable end self end |
#resume ⇒ Trip::Event?
Resumes a fiber.
47 48 49 50 51 |
# File 'lib/trip/fiber.rb', line 47 def resume @fiber.resume rescue FiberError nil end |