Class: Phut::Syntax::VhostDirective

Inherits:
Directive
  • Object
show all
Defined in:
lib/phut/syntax/vhost_directive.rb

Overview

The ‘vhost(name) { …attributes… }’ directive.

Defined Under Namespace

Classes: UnusedIpAddress

Constant Summary collapse

UnusedIpAddressSingleton =
UnusedIpAddress.new

Instance Method Summary collapse

Methods inherited from Directive

#[], attribute

Constructor Details

#initialize(alias_name, &block) ⇒ VhostDirective

Returns a new instance of VhostDirective.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/phut/syntax/vhost_directive.rb', line 24

def initialize(alias_name, &block)
  @attributes =
    { name: alias_name,
      mac: Pio::Mac.new(rand(0xffffffffffff + 1)),
      promisc: false }
  if block
    instance_eval(&block)
  else
    @attributes[:ip] = UnusedIpAddressSingleton.generate
  end
end

Instance Method Details

#ip(value) ⇒ Object



36
37
38
39
# File 'lib/phut/syntax/vhost_directive.rb', line 36

def ip(value)
  @attributes[:ip] = value
  @attributes[:name] ||= value
end