Class: SshConfig::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh_config/entry.rb

Overview

SshHost represents a single Host entry in an ssh_config(5)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*names) ⇒ Entry

Returns a new instance of Entry.



8
9
10
# File 'lib/ssh_config/entry.rb', line 8

def initialize(*names)
  @names = Array(names).flatten.map { |name| String(name) }
end

Instance Attribute Details

#userObject

Returns the value of attribute user.



6
7
8
# File 'lib/ssh_config/entry.rb', line 6

def user
  @user
end

Instance Method Details

#distinct_namesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ssh_config/entry.rb', line 12

def distinct_names
  @distinct_names ||= begin
    no_ips = @names
      .sort(&:count)
      .reject { |name| name =~ /\A\d+\.\d+\.\d+\.\d+\Z/ }

    no_ips
      .reject do |name|
        parts = name.split('.')
        parts.count != 1 && no_ips.include?(parts.first)
      end
  end
end