Class: Phut::Syntax
- Inherits:
-
Object
- Object
- Phut::Syntax
- Defined in:
- lib/phut/syntax.rb
Overview
DSL syntax definitions.
Defined Under Namespace
Classes: LinkDirective, VhostDirective, VswitchDirective
Instance Method Summary collapse
-
#initialize(config) ⇒ Syntax
constructor
A new instance of Syntax.
- #link(name_a, name_b) ⇒ Object
- #vhost(alias_name = nil, &block) ⇒ Object
- #vswitch(alias_name = nil, &block) ⇒ Object
Constructor Details
#initialize(config) ⇒ Syntax
Returns a new instance of Syntax.
102 103 104 105 |
# File 'lib/phut/syntax.rb', line 102 def initialize(config) @config = config LinkDirective::LinkIdSingleton.init end |
Instance Method Details
#link(name_a, name_b) ⇒ Object
117 118 119 120 121 |
# File 'lib/phut/syntax.rb', line 117 def link(name_a, name_b) link_id = @config.links.size attrs = LinkDirective.new(name_a, name_b, link_id) @config.add_link name_a, attrs[:device_a], name_b, attrs[:device_b] end |
#vhost(alias_name = nil, &block) ⇒ Object
112 113 114 115 |
# File 'lib/phut/syntax.rb', line 112 def vhost(alias_name = nil, &block) attrs = VhostDirective.new(alias_name, &block) @config.add_vhost attrs[:name], attrs end |
#vswitch(alias_name = nil, &block) ⇒ Object
107 108 109 110 |
# File 'lib/phut/syntax.rb', line 107 def vswitch(alias_name = nil, &block) attrs = VswitchDirective.new(alias_name, &block) @config.add_vswitch attrs[:name], attrs end |