Class: Yapfac::Apache::Directive
- Inherits:
-
Object
- Object
- Yapfac::Apache::Directive
- Defined in:
- lib/yapfac/apache/directive.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#params ⇒ Object
Returns the value of attribute params.
Class Method Summary collapse
-
.parse(line) ⇒ Yapfac::Apache::Directive
Parses a directive string into a directive object.
Instance Method Summary collapse
-
#initialize(name, *params) ⇒ Directive
constructor
Initialize a new Directive, given an array and arbitrary number of params.
-
#to_h ⇒ Hash
Builds a hash representation of the Apache Directive, useful for serialization.
-
#to_s ⇒ String
Builds a string representation of the directive, which is valid for storing in an Apache configuration file.
Constructor Details
#initialize(name, *params) ⇒ Directive
Initialize a new Directive, given an array and arbitrary number of params.
12 13 14 15 |
# File 'lib/yapfac/apache/directive.rb', line 12 def initialize(name, *params) @name = name @params = params end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/yapfac/apache/directive.rb', line 5 def name @name end |
#params ⇒ Object
Returns the value of attribute params.
5 6 7 |
# File 'lib/yapfac/apache/directive.rb', line 5 def params @params end |
Class Method Details
.parse(line) ⇒ Yapfac::Apache::Directive
Parses a directive string into a directive object. This is most often used when reading in from a file.
42 43 44 45 |
# File 'lib/yapfac/apache/directive.rb', line 42 def self.parse(name, params = nil) name, params = name.split /\s+/, 2 if params.nil? return Yapfac::Apache::Directive.new(name, *parse_params(params)) end |
Instance Method Details
#to_h ⇒ Hash
Builds a hash representation of the Apache Directive, useful for serialization.
71 72 73 74 75 76 |
# File 'lib/yapfac/apache/directive.rb', line 71 def to_h return ({ name: @name, params: @params }) end |
#to_s ⇒ String
Builds a string representation of the directive, which is valid for storing in an Apache configuration file.
52 53 54 55 56 57 58 59 60 |
# File 'lib/yapfac/apache/directive.rb', line 52 def to_s "#{@name} #{@params.collect do |p| if p =~ /\s/ "\"#{p}\"" else p end end.join(' ')}" end |