Sha256: 181c363e30d40c34cfeb8ad625a973d07e2fba4d01719f3be6a800f4ba7cbe36
Contents?: true
Size: 921 Bytes
Versions: 3
Compression:
Stored size: 921 Bytes
Contents
require 'phut/syntax/directive' module Phut class Syntax # The 'vhost(name) { ...attributes... }' directive. class VhostDirective < Directive # Generates an unused IP address class UnusedIpAddress def initialize @index = 0 end def generate @index += 1 "192.168.0.#{@index}" end end UnusedIpAddressSingleton = UnusedIpAddress.new attribute :mac attribute :promisc 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 def ip(value) @attributes[:ip] = value @attributes[:name] ||= value end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
phut-0.7.7 | lib/phut/syntax/vhost_directive.rb |
phut-0.7.6 | lib/phut/syntax/vhost_directive.rb |
phut-0.7.5 | lib/phut/syntax/vhost_directive.rb |