Class: Fig::Package::Configuration
- Inherits:
-
Object
- Object
- Fig::Package::Configuration
- Includes:
- Statement
- Defined in:
- lib/fig/package/configuration.rb
Overview
A grouping of statements within a configuration. May not be nested.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#statements ⇒ Object
readonly
Returns the value of attribute statements.
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(name, statements) ⇒ Configuration
constructor
A new instance of Configuration.
- #unparse(indent) ⇒ Object
- #walk_statements(&block) ⇒ Object
- #with_name(name) ⇒ Object
Methods included from Statement
Constructor Details
#initialize(name, statements) ⇒ Configuration
Returns a new instance of Configuration.
15 16 17 18 |
# File 'lib/fig/package/configuration.rb', line 15 def initialize(name, statements) @name = name @statements = statements end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/fig/package/configuration.rb', line 13 def name @name end |
#statements ⇒ Object (readonly)
Returns the value of attribute statements.
13 14 15 |
# File 'lib/fig/package/configuration.rb', line 13 def statements @statements end |
Instance Method Details
#command ⇒ Object
24 25 26 27 28 |
# File 'lib/fig/package/configuration.rb', line 24 def command return statements.find do |statement| statement.is_a?(Fig::Package::Command) end end |
#unparse(indent) ⇒ Object
37 38 39 |
# File 'lib/fig/package/configuration.rb', line 37 def unparse(indent) unparse_statements(indent, "config #{@name}", @statements, 'end') end |
#walk_statements(&block) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/fig/package/configuration.rb', line 30 def walk_statements(&block) @statements.each do |statement| yield statement statement.walk_statements &block end end |
#with_name(name) ⇒ Object
20 21 22 |
# File 'lib/fig/package/configuration.rb', line 20 def with_name(name) Configuration.new(name, statements) end |