Class: TBM::Config
- Inherits:
-
Object
- Object
- TBM::Config
- Defined in:
- lib/TBM/config.rb
Overview
Configuration for the Tunnel Boring Machine. This class is both the parser of the configuration data in YAML form, and the artifact that results from the parsing.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Any errors discovered while parsing the configuration.
-
#targets ⇒ Object
readonly
The targets defined in the configuration.
Instance Method Summary collapse
-
#each_target {|target| ... } ⇒ Object
Iterate over each target and yield to the specified block.
-
#get_target(name) ⇒ Object
Request a target having the specified name.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#valid? ⇒ Boolean
The configuration is valid if there are no errors.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
13 14 15 16 |
# File 'lib/TBM/config.rb', line 13 def initialize @errors = [] @targets = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Any errors discovered while parsing the configuration.
8 9 10 |
# File 'lib/TBM/config.rb', line 8 def errors @errors end |
#targets ⇒ Object (readonly)
The targets defined in the configuration.
11 12 13 |
# File 'lib/TBM/config.rb', line 11 def targets @targets end |
Instance Method Details
#each_target {|target| ... } ⇒ Object
Iterate over each target and yield to the specified block.
35 36 37 |
# File 'lib/TBM/config.rb', line 35 def each_target( &block ) @targets.each { |target| yield target } end |
#get_target(name) ⇒ Object
Request a target having the specified name.
28 29 30 |
# File 'lib/TBM/config.rb', line 28 def get_target( name ) @targets.find { |target| target.has_name?(name) } end |
#valid? ⇒ Boolean
The configuration is valid if there are no errors.
21 22 23 |
# File 'lib/TBM/config.rb', line 21 def valid? @errors.empty? end |