Class: NginxConfigParser::Section
- Inherits:
-
Configuration
- Object
- Configuration
- NginxConfigParser::Section
- Defined in:
- lib/nginx_config_parser/configuration.rb
Overview
A Section of settings
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Configuration
Instance Method Summary collapse
-
#initialize(level, name, value = nil) ⇒ Section
constructor
A new instance of Section.
-
#to_s ⇒ Object
:nodoc:.
Methods inherited from Configuration
#[]=, #each, #section, #sections
Constructor Details
#initialize(level, name, value = nil) ⇒ Section
Returns a new instance of Section.
49 50 51 52 53 |
# File 'lib/nginx_config_parser/configuration.rb', line 49 def initialize(level, name, value=nil) @name = name @value = value super(level) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
48 49 50 |
# File 'lib/nginx_config_parser/configuration.rb', line 48 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
48 49 50 |
# File 'lib/nginx_config_parser/configuration.rb', line 48 def value @value end |
Instance Method Details
#to_s ⇒ Object
:nodoc:
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/nginx_config_parser/configuration.rb', line 55 def to_s #:nodoc: lines = [] lines << ((' ' * (@level - 1)) << [@name, Array(@value)].flatten.compact.map { |v| v.to_s }.join(' ') << ' {') @settings.each do |key, value| lines << ((' ' * @level) << [key, Array(value)].flatten.join(' ') << ';') end lines.push(*sections.map { |section| section.to_s}) lines << ((' ' * (@level - 1)) << '}') lines.join("\n") end |