Class: Fig::Statement::Configuration
- Inherits:
-
Fig::Statement
- Object
- Fig::Statement
- Fig::Statement::Configuration
- Defined in:
- lib/fig/statement/configuration.rb
Overview
A grouping of statements within a package. May not be nested.
Any processing of statements is guaranteed to hit any Overrides first.
Constant Summary
Constants inherited from Fig::Statement
ENVIRONMENT_VARIABLE_NAME_REGEX
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#statements ⇒ Object
readonly
Returns the value of attribute statements.
Attributes inherited from Fig::Statement
#column, #line, #source_description
Instance Method Summary collapse
- #command_statement ⇒ Object
-
#initialize(line_column, source_description, name, statements) ⇒ Configuration
constructor
A new instance of Configuration.
- #unparse(indent) ⇒ Object
-
#walk_statements(&block) ⇒ Object
Block will receive a Statement.
Methods inherited from Fig::Statement
#is_asset?, position_description, #position_string, #urls
Constructor Details
#initialize(line_column, source_description, name, statements) ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fig/statement/configuration.rb', line 12 def initialize(line_column, source_description, name, statements) super(line_column, source_description) @name = name overrides, others = statements.partition do |statement| statement.is_a?(Fig::Statement::Override) end @statements = [overrides, others].flatten end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/fig/statement/configuration.rb', line 10 def name @name end |
#statements ⇒ Object (readonly)
Returns the value of attribute statements.
10 11 12 |
# File 'lib/fig/statement/configuration.rb', line 10 def statements @statements end |
Instance Method Details
#command_statement ⇒ Object
24 25 26 27 28 |
# File 'lib/fig/statement/configuration.rb', line 24 def command_statement return statements.find do |statement| statement.is_a?(Fig::Statement::Command) end end |
#unparse(indent) ⇒ Object
38 39 40 |
# File 'lib/fig/statement/configuration.rb', line 38 def unparse(indent) unparse_statements(indent, "config #{@name}", @statements, 'end') end |
#walk_statements(&block) ⇒ Object
Block will receive a Statement.
31 32 33 34 35 36 |
# File 'lib/fig/statement/configuration.rb', line 31 def walk_statements(&block) @statements.each do |statement| yield statement statement.walk_statements &block end end |