Class: Phut::Syntax::NetnsDirective
- Defined in:
- lib/phut/syntax/netns_directive.rb
Overview
The ‘netns(name) { …attributes… }’ directive.
Instance Method Summary collapse
-
#initialize(alias_name, &block) ⇒ NetnsDirective
constructor
A new instance of NetnsDirective.
- #ip(value) ⇒ Object
- #mac(value) ⇒ Object
- #route(options) ⇒ Object
- #vlan(value) ⇒ Object
Methods inherited from Directive
#[], attribute, #method_missing
Constructor Details
#initialize(alias_name, &block) ⇒ NetnsDirective
Returns a new instance of NetnsDirective.
11 12 13 14 15 |
# File 'lib/phut/syntax/netns_directive.rb', line 11 def initialize(alias_name, &block) @attributes = { name: alias_name, netmask: '255.255.255.255' } instance_eval(&block) if block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Phut::Syntax::Directive
Instance Method Details
#ip(value) ⇒ Object
17 18 19 20 |
# File 'lib/phut/syntax/netns_directive.rb', line 17 def ip(value) @attributes[:ip] = value @attributes[:name] ||= value end |
#mac(value) ⇒ Object
27 28 29 |
# File 'lib/phut/syntax/netns_directive.rb', line 27 def mac(value) @attributes[:mac_address] = value end |
#route(options) ⇒ Object
22 23 24 25 |
# File 'lib/phut/syntax/netns_directive.rb', line 22 def route() @attributes[:net] = .fetch(:net) @attributes[:gateway] = .fetch(:gateway) end |
#vlan(value) ⇒ Object
31 32 33 |
# File 'lib/phut/syntax/netns_directive.rb', line 31 def vlan(value) @attributes[:vlan] = value end |