Class: Phut::Syntax::VhostDirective
- Inherits:
-
Object
- Object
- Phut::Syntax::VhostDirective
- Defined in:
- lib/phut/syntax.rb
Overview
The ‘vhost(name) { …attributes… }’ directive.
Defined Under Namespace
Classes: UnusedIpAddress
Constant Summary collapse
- UnusedIpAddressSingleton =
UnusedIpAddress.new
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(alias_name, &block) ⇒ VhostDirective
constructor
A new instance of VhostDirective.
- #ip(value) ⇒ Object
- #mac(value) ⇒ Object
- #promisc(on_off) ⇒ Object
Constructor Details
#initialize(alias_name, &block) ⇒ VhostDirective
51 52 53 54 55 56 57 58 59 |
# File 'lib/phut/syntax.rb', line 51 def initialize(alias_name, &block) @attributes = { name: alias_name, mac: Pio::Mac.new(rand(0xffffffffffff + 1)) } if block instance_eval(&block) if block else @attributes[:ip] = UnusedIpAddressSingleton.generate end end |
Instance Method Details
#[](key) ⇒ Object
74 75 76 |
# File 'lib/phut/syntax.rb', line 74 def [](key) @attributes[key] end |
#ip(value) ⇒ Object
61 62 63 64 |
# File 'lib/phut/syntax.rb', line 61 def ip(value) @attributes[:ip] = value @attributes[:name] ||= value end |
#mac(value) ⇒ Object
66 67 68 |
# File 'lib/phut/syntax.rb', line 66 def mac(value) @attributes[:mac] = value end |
#promisc(on_off) ⇒ Object
70 71 72 |
# File 'lib/phut/syntax.rb', line 70 def promisc(on_off) @attributes[:promisc] = on_off end |