Class: Inprovise::ScriptIndex
- Inherits:
-
Object
- Object
- Inprovise::ScriptIndex
- Defined in:
- lib/inprovise/script_index.rb
Overview
Script Index for Inprovise
- Author
-
Martin Corino
- License
-
Distributes under the same license as Ruby
Defined Under Namespace
Classes: MissingScriptError
Instance Attribute Summary collapse
-
#index_name ⇒ Object
readonly
Returns the value of attribute index_name.
Class Method Summary collapse
Instance Method Summary collapse
- #add(scr) ⇒ Object
- #clear! ⇒ Object
- #get(scr_name) ⇒ Object
-
#initialize(index_name) ⇒ ScriptIndex
constructor
A new instance of ScriptIndex.
- #scripts ⇒ Object
Constructor Details
#initialize(index_name) ⇒ ScriptIndex
Returns a new instance of ScriptIndex.
9 10 11 12 |
# File 'lib/inprovise/script_index.rb', line 9 def initialize(index_name) @index_name = index_name @scripts = {} end |
Instance Attribute Details
#index_name ⇒ Object (readonly)
Returns the value of attribute index_name.
7 8 9 |
# File 'lib/inprovise/script_index.rb', line 7 def index_name @index_name end |
Class Method Details
.default ⇒ Object
14 15 16 |
# File 'lib/inprovise/script_index.rb', line 14 def self.default @default ||= new('default') end |
Instance Method Details
#add(scr) ⇒ Object
18 19 20 |
# File 'lib/inprovise/script_index.rb', line 18 def add(scr) @scripts[scr.name] = scr end |
#clear! ⇒ Object
32 33 34 |
# File 'lib/inprovise/script_index.rb', line 32 def clear! @scripts = {} end |
#get(scr_name) ⇒ Object
22 23 24 25 26 |
# File 'lib/inprovise/script_index.rb', line 22 def get(scr_name) scr = @scripts[scr_name] raise MissingScriptError.new(index_name, scr_name) if scr.nil? scr end |
#scripts ⇒ Object
28 29 30 |
# File 'lib/inprovise/script_index.rb', line 28 def scripts @scripts.keys end |