Class: OpsWalrus::Namespace
- Inherits:
-
Object
- Object
- OpsWalrus::Namespace
- Defined in:
- lib/opswalrus/runtime_environment.rb
Overview
Namespace is really just a Map of symbol_name -> (Namespace | OpsFile) pairs
Instance Attribute Summary collapse
-
#dirname ⇒ Object
Returns the value of attribute dirname.
-
#runtime_env ⇒ Object
Returns the value of attribute runtime_env.
-
#symbol_table ⇒ Object
Returns the value of attribute symbol_table.
Instance Method Summary collapse
- #add(symbol_name, ops_file_or_child_namespace) ⇒ Object
-
#initialize(runtime_env, dirname) ⇒ Namespace
constructor
dirname is an absolute path.
- #resolve_symbol(symbol_name) ⇒ Object
- #to_s(indent = 0) ⇒ Object
Constructor Details
#initialize(runtime_env, dirname) ⇒ Namespace
dirname is an absolute path
85 86 87 88 89 |
# File 'lib/opswalrus/runtime_environment.rb', line 85 def initialize(runtime_env, dirname) @runtime_env = runtime_env @dirname = dirname @symbol_table = {} # "symbol_name" => ops_file_or_child_namespace end |
Instance Attribute Details
#dirname ⇒ Object
Returns the value of attribute dirname.
81 82 83 |
# File 'lib/opswalrus/runtime_environment.rb', line 81 def dirname @dirname end |
#runtime_env ⇒ Object
Returns the value of attribute runtime_env.
80 81 82 |
# File 'lib/opswalrus/runtime_environment.rb', line 80 def runtime_env @runtime_env end |
#symbol_table ⇒ Object
Returns the value of attribute symbol_table.
82 83 84 |
# File 'lib/opswalrus/runtime_environment.rb', line 82 def symbol_table @symbol_table end |
Instance Method Details
#add(symbol_name, ops_file_or_child_namespace) ⇒ Object
103 104 105 |
# File 'lib/opswalrus/runtime_environment.rb', line 103 def add(symbol_name, ops_file_or_child_namespace) @symbol_table[symbol_name.to_s] = ops_file_or_child_namespace end |
#resolve_symbol(symbol_name) ⇒ Object
107 108 109 |
# File 'lib/opswalrus/runtime_environment.rb', line 107 def resolve_symbol(symbol_name) @symbol_table[symbol_name.to_s] end |
#to_s(indent = 0) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/opswalrus/runtime_environment.rb', line 91 def to_s(indent = 0) str = "Namespace: #{@dirname.to_s}\n" @symbol_table.each do |k, v| if v.is_a? Namespace str << "#{' ' * (indent)}|- #{k} : #{v.to_s(indent + 1)}" else str << "#{' ' * (indent)}|- #{k} : #{v.to_s}\n" end end str end |