Class: Puffy::Formatters::Base::Ruleset
- Inherits:
-
Object
- Object
- Puffy::Formatters::Base::Ruleset
- Defined in:
- lib/puffy/formatters/base.rb
Overview
Base class for Puffy Formatter Rulesets
Direct Known Subclasses
Instance Method Summary collapse
- #emit_header ⇒ Object
-
#emit_ruleset(rules, _policy = nil) ⇒ String
Returns a String representation of the provided
rulesArray of Puffy::Rule with thepolicypolicy. -
#filename_fragment ⇒ Array<String>
Filename for a firewall configuration fragment emitted by the formatter.
-
#initialize ⇒ Ruleset
constructor
A new instance of Ruleset.
Constructor Details
#initialize ⇒ Ruleset
Returns a new instance of Ruleset.
29 30 31 |
# File 'lib/puffy/formatters/base.rb', line 29 def initialize @rule_formatter = Class.const_get(self.class.name.sub(/set$/, '')).new end |
Instance Method Details
#emit_header ⇒ Object
33 34 35 |
# File 'lib/puffy/formatters/base.rb', line 33 def emit_header ["# Generated by puffy v#{Puffy::VERSION} on #{Time.now.strftime('%c')}"] end |
#emit_ruleset(rules, _policy = nil) ⇒ String
Returns a String representation of the provided rules Array of Puffy::Rule with the policy policy.
42 43 44 |
# File 'lib/puffy/formatters/base.rb', line 42 def emit_ruleset(rules, _policy = nil) rules.collect { |rule| @rule_formatter.emit_rule(rule) }.join("\n") end |
#filename_fragment ⇒ Array<String>
Filename for a firewall configuration fragment emitted by the formatter.
49 50 51 |
# File 'lib/puffy/formatters/base.rb', line 49 def filename_fragment raise 'Formatters#filename_fragment MUST be overriden' end |