Class: IPTables::Macro
- Inherits:
-
Object
- Object
- IPTables::Macro
- Defined in:
- lib/iptables/expansions.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_child(rule_hash) ⇒ Object
- #handle_array ⇒ Object
- #handle_hash ⇒ Object
- #handle_string ⇒ Object
-
#initialize(name, info) ⇒ Macro
constructor
A new instance of Macro.
Constructor Details
#initialize(name, info) ⇒ Macro
Returns a new instance of Macro.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/iptables/expansions.rb', line 17 def initialize(name, info) @name = name @info = info @children = [] case info when Array self.handle_array() when Hash self.handle_hash() when String self.handle_string() else raise "don't know how to handle info: #{info.inspect}" end end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
16 17 18 |
# File 'lib/iptables/expansions.rb', line 16 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/iptables/expansions.rb', line 16 def name @name end |
Instance Method Details
#add_child(rule_hash) ⇒ Object
34 35 36 |
# File 'lib/iptables/expansions.rb', line 34 def add_child(rule_hash) @children.push(rule_hash) end |
#handle_array ⇒ Object
38 39 40 41 42 |
# File 'lib/iptables/expansions.rb', line 38 def handle_array() @info.each{ |macro_hash| self.add_child(macro_hash) } end |
#handle_hash ⇒ Object
44 45 46 |
# File 'lib/iptables/expansions.rb', line 44 def handle_hash() self.add_child( @info ) end |
#handle_string ⇒ Object
48 49 50 |
# File 'lib/iptables/expansions.rb', line 48 def handle_string() self.add_child( {'raw' => @info} ) end |