Class: Actor::Filter
- Inherits:
-
Object
- Object
- Actor::Filter
- Defined in:
- lib/girl_friday/actor.rb
Instance Attribute Summary (collapse)
-
- (Object) timeout
readonly
Returns the value of attribute timeout.
-
- (Object) timeout_action
readonly
Returns the value of attribute timeout_action.
Instance Method Summary (collapse)
- - (Object) action_for(value)
- - (Object) after(seconds, &action)
-
- (Filter) initialize
constructor
A new instance of Filter.
- - (Boolean) timeout?
- - (Object) when(pattern, &action)
Constructor Details
- (Filter) initialize
A new instance of Filter
438 439 440 441 442 |
# File 'lib/girl_friday/actor.rb', line 438 def initialize @pairs = [] @timeout = nil @timeout_action = nil end |
Instance Attribute Details
- (Object) timeout (readonly)
Returns the value of attribute timeout
435 436 437 |
# File 'lib/girl_friday/actor.rb', line 435 def timeout @timeout end |
- (Object) timeout_action (readonly)
Returns the value of attribute timeout_action
436 437 438 |
# File 'lib/girl_friday/actor.rb', line 436 def timeout_action @timeout_action end |
Instance Method Details
- (Object) action_for(value)
465 466 467 468 |
# File 'lib/girl_friday/actor.rb', line 465 def action_for(value) pair = @pairs.find { |pattern, action| pattern === value } pair ? pair.last : nil end |
- (Object) after(seconds, &action)
454 455 456 457 458 459 460 461 462 463 |
# File 'lib/girl_friday/actor.rb', line 454 def after(seconds, &action) raise ArgumentError, "no block given" unless action seconds = seconds.to_f if !@timeout or seconds < @timeout @timeout = seconds @timeout_action = action end self end |
- (Boolean) timeout?
444 445 446 |
# File 'lib/girl_friday/actor.rb', line 444 def timeout? not @timeout.nil? end |
- (Object) when(pattern, &action)
448 449 450 451 452 |
# File 'lib/girl_friday/actor.rb', line 448 def when(pattern, &action) raise ArgumentError, "no block given" unless action @pairs.push [pattern, action] self end |