Class: Rules
- Inherits:
-
Object
- Object
- Rules
- Defined in:
- lib/netconfdev/vrouter/rules.rb
Overview
The class that defines firewall Rules.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
String: Name of the firewall rule.
-
#rules ⇒ Object
readonly
List of Rule : List of Rule defining the firewall behavior.
Instance Method Summary collapse
-
#add_rule(rule) ⇒ Object
Add a rule to this firewall.
-
#initialize(name: nil) ⇒ Rules
constructor
- Parameters *
name -
String: Name of the firewall rule.
- Parameters *
-
#to_hash ⇒ Object
:nodoc:.
Constructor Details
#initialize(name: nil) ⇒ Rules
Parameters
name-
String: Name of the firewall rule.
44 45 46 47 48 49 |
# File 'lib/netconfdev/vrouter/rules.rb', line 44 def initialize(name: nil) raise ArgumentError, "Name (name) required" unless name @name = name @rules = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
String: Name of the firewall rule.
36 37 38 |
# File 'lib/netconfdev/vrouter/rules.rb', line 36 def name @name end |
#rules ⇒ Object (readonly)
List of Rule : List of Rule defining the firewall behavior.
39 40 41 |
# File 'lib/netconfdev/vrouter/rules.rb', line 39 def rules @rules end |
Instance Method Details
#add_rule(rule) ⇒ Object
Add a rule to this firewall.
Parameters
rule-
Rule : A Firewall Rule to add to this Firewall.
57 58 59 60 |
# File 'lib/netconfdev/vrouter/rules.rb', line 57 def add_rule(rule) raise ArgumentError, "Rule must be instance of 'Rule'" unless rule.is_a?(Rule) @rules << rule end |
#to_hash ⇒ Object
:nodoc:
62 63 64 65 66 67 68 |
# File 'lib/netconfdev/vrouter/rules.rb', line 62 def to_hash #:nodoc: rules_hash = [] @rules.each do |rule| rules_hash << rule.to_hash end {:rule => rules_hash, :tagnode => @name} end |