aboutsummaryrefslogtreecommitdiff
path: root/lib/host.rb
blob: 90c3e2e8790d4ef781357cfc928ff2a62f141638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module SSHConfig
  class Host
    def initialize(name, &block)
      @name = name
      @directives = {}
      self.instance_eval(&block)
    end

    def method_missing(meth, arg)
      @directives[meth.capitalize] = arg
    end

    def to_s
      "Host #{@name}\n" +
      @directives.map { |k, v| "\t#{k} #{v}" }.join("\n") +
      "\n"
    end
  end
end