Class Limelight::Theater
In: lib/limelight/theater.rb
Parent: Object

A Theater represents a group of Stages. Productions require a Theater in which to open.

Methods

Included Modules

UI::Api::Theater

Attributes

active_stage  [R]  Returns the theater‘s active stage. i.e. the stage most recently used.

Public Class methods

[Source]

    # File lib/limelight/theater.rb, line 19
19:     def initialize(production)
20:       @production = production
21:       @stages = {}
22:       @mutex = Mutex.new
23:     end

Public Instance methods

Returns the Stage with the spcified name, nil if none exist with the specified name.

[Source]

    # File lib/limelight/theater.rb, line 39
39:     def [](stage_name)
40:       return @mutex.synchronize { @stages[stage_name] }
41:     end

Adds a Stage to the Theater. Raises an exception is the name of the Stage is duplicated.

[Source]

    # 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.

[Source]

    # 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

If no Stages are added, the Theater will provide a default Stage named "Limelight".

[Source]

    # File lib/limelight/theater.rb, line 77
77:     def default_stage
78:       add_stage("Limelight") if self["Limelight"].nil?
79:       return self["Limelight"]
80:     end

Returns true if the theater has at least one stage

[Source]

    # File lib/limelight/theater.rb, line 33
33:     def has_stages?
34:       return stages.length > 0
35:     end

Invoked when a stage, blonging to this theater becomes active. Lets the Theater know which stage has the limelight (currently active). Only 1 stage may be active at a time.

[Source]

    # File lib/limelight/theater.rb, line 55
55:     def stage_activated(stage)
56:       @active_stage = stage
57:     end

Removes the stage from this theater.

[Source]

    # 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.

[Source]

    # 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

Returns an Array of Stages that belong to this Theater.

[Source]

    # File lib/limelight/theater.rb, line 27
27:     def stages
28:       return @mutex.synchronize { @stages.values }
29:     end

Protected Instance methods

[Source]

    # File lib/limelight/theater.rb, line 93
93:     def build_stage(name, options)
94:       return Limelight::Stage.new(self, name, options)
95:     end

[Validate]