aboutsummaryrefslogtreecommitdiff
path: root/lib/hosts.rb
blob: 1917b9392c558ef9afa7062ec697b49ae51a9d30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module SSHConfig
  class Hosts
    attr_reader :hosts

    def initialize(&block)
      @hosts = []
      self.instance_eval(&block)
    end

    def merge(morehosts)
      @hosts += morehosts.hosts
    end

    def host(name, &blk)
      @hosts << Host.new(name, &blk)
    end

    def to_s
      @hosts.map(&:to_s).join("\n")
    end
  end
end