# File lib/sshkit/host.rb, line 23 def initialize(host_string_or_options_hash) unless host_string_or_options_hash.is_a?(Hash) suitable_parsers = [ SimpleHostParser, HostWithPortParser, HostWithUsernameAndPortParser, IPv6HostWithPortParser, HostWithUsernameParser, ].select do |p| p.suitable?(host_string_or_options_hash) end if suitable_parsers.any? suitable_parsers.first.tap do |parser| @user, @hostname, @port = parser.new(host_string_or_options_hash).attributes end else raise UnparsableHostStringError, "Cannot parse host string #{host_string_or_options_hash}" end else host_string_or_options_hash.each do |key, value| if self.respond_to?("#{key}=") send("#{key}=", value) else raise ArgumentError, "Unknown host property #{key}" end end end end
# File lib/sshkit/host.rb, line 62 def eql?(other_host) other_host.hash == hash end
# File lib/sshkit/host.rb, line 54 def hash user.hash ^ hostname.hash ^ port.hash end
# File lib/sshkit/host.rb, line 11 def key=(new_key) @keys = [new_key] end
# File lib/sshkit/host.rb, line 15 def keys=(new_keys) @keys = new_keys end
# File lib/sshkit/host.rb, line 72 def netssh_options {}.tap do |sho| sho[:keys] = keys if keys.any? sho[:port] = port if port sho[:user] = user if user sho[:password] = password if password sho[:forward_agent] = true end .merge(ssh_options || {}) end
Generated with the Darkfish Rdoc Generator 2.