Class: Fig::Package::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Statement

#urls

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

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/fig/package/configuration.rb', line 13

def name
  @name
end

#statementsObject (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

#commandObject



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