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
Returns a new instance of VhostDirective.
50 51 52 53 54 55 56 57 58 |
# File 'lib/phut/syntax.rb', line 50 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
73 74 75 |
# File 'lib/phut/syntax.rb', line 73 def [](key) @attributes[key] end |
#ip(value) ⇒ Object
60 61 62 63 |
# File 'lib/phut/syntax.rb', line 60 def ip(value) @attributes[:ip] = value @attributes[:name] ||= value end |
#mac(value) ⇒ Object
65 66 67 |
# File 'lib/phut/syntax.rb', line 65 def mac(value) @attributes[:mac] = value end |
#promisc(on_off) ⇒ Object
69 70 71 |
# File 'lib/phut/syntax.rb', line 69 def promisc(on_off) @attributes[:promisc] = on_off end |