Class | Limelight::Theater |
In: |
lib/limelight/theater.rb
|
Parent: | Object |
active_stage | [R] | Returns the theater‘s active stage. i.e. the stage most recently used. |
# File lib/limelight/theater.rb, line 19 19: def initialize(production) 20: @production = production 21: @stages = {} 22: @mutex = Mutex.new 23: end
Adds a Stage to the Theater. Raises an exception is the name of the Stage is duplicated.
# File lib/limelight/theater.rb, line 45 45: def add_stage(name, options = {}) 46: raise LimelightException.new("Duplicate stage name: '#{name}'") if @stages[name] 47: stage = build_stage(name, options) 48: @mutex.synchronize { @stages[name] = stage } 49: return stage 50: end
Close this theater. All stages in this theater will be closed and the active_stage will be nil‘ed.
# File lib/limelight/theater.rb, line 84 84: def close 85: stages_to_close = @mutex.synchronize { @stages.values.dup } 86: stages_to_close.each { |stage| stage.close } 87: @mutex.synchronize { @stages.clear } 88: @active_stage = nil 89: end
Returns true if the theater has at least one stage
# File lib/limelight/theater.rb, line 33 33: def has_stages? 34: return stages.length > 0 35: end
Removes the stage from this theater.
# File lib/limelight/theater.rb, line 69 69: def stage_closed(stage) 70: @mutex.synchronize { @stages.delete(stage.name) } 71: @active_stage = nil if @active_stage == stage 72: @production.theater_empty! if !any_stages? || !any_visible_stages? 73: end
Invoked when a stage, belonging to this theater, loose it‘s status as the active stage. The active_stage is cleared. Only 1 stage may be active at a time.
# File lib/limelight/theater.rb, line 62 62: def stage_deactivated(stage) 63: @active_stage = nil 64: @production.theater_empty! if !any_visible_stages? 65: end