class ServerSettings::HostCollection

Public Class Methods

new(hosts, role_config) click to toggle source
# File lib/server_settings/host_collection.rb, line 4
def initialize(hosts, role_config)
  @role_config = role_config
  unless hosts.kind_of?(Array)
    raise InvalidHosts, "hosts: #{hosts} is not array"
  end

  hosts.each do |host_exp|
    self.push Host.parse(host_exp)
  end
end

Public Instance Methods

with_format(format) click to toggle source
# File lib/server_settings/host_collection.rb, line 15
def with_format(format)
  self.map do |host|
    replacemap = @role_config
    replacemap['%host'] = host.host
    replacemap['%port'] = host.port if host.port
    replacemap.inject(format) do |string, mapping|
      string.gsub(*mapping)
    end
  end
end