Class: WizTeleport::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/wiz-teleport/group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Group

Returns a new instance of Group.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/wiz-teleport/group.rb', line 8

def initialize(options = {})
  options = options.transform_keys(&:to_sym)
  @name = options[:name]
  @children = options[:children] || []
  @user = options[:user] || 'root'
  @password = options[:password]
  @port = options[:port] || 22
  @servers = (options[:servers] || []).map do |server_data|
    server_data[:user] ||= @user
    server_data[:password] ||= @password
    server_data[:port] ||= @port
    Server.new(server_data)
  end
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



6
7
8
# File 'lib/wiz-teleport/group.rb', line 6

def children
  @children
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/wiz-teleport/group.rb', line 6

def name
  @name
end

#passwordObject (readonly)

Returns the value of attribute password.



6
7
8
# File 'lib/wiz-teleport/group.rb', line 6

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



6
7
8
# File 'lib/wiz-teleport/group.rb', line 6

def port
  @port
end

#serversObject (readonly)

Returns the value of attribute servers.



6
7
8
# File 'lib/wiz-teleport/group.rb', line 6

def servers
  @servers
end

#userObject (readonly)

Returns the value of attribute user.



6
7
8
# File 'lib/wiz-teleport/group.rb', line 6

def user
  @user
end

Instance Method Details

#to_hObject



23
24
25
26
27
28
29
30
31
# File 'lib/wiz-teleport/group.rb', line 23

def to_h
  h = {'name' => @name}
  h['servers'] = @servers.map(&:to_h)
  h['children'] = @children if @children
  h['user'] = @user if @user
  h['password'] = @password if @password
  h['port'] = @port if @port
  h
end