Class: WizTeleport::Group
- Inherits:
-
Object
- Object
- WizTeleport::Group
- Defined in:
- lib/wiz-teleport/group.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#servers ⇒ Object
readonly
Returns the value of attribute servers.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Group
constructor
A new instance of Group.
- #to_h ⇒ Object
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( = {}) = .transform_keys(&:to_sym) @name = [:name] @children = [:children] || [] @user = [:user] || 'root' @password = [:password] @port = [:port] || 22 @servers = ([: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
#children ⇒ Object (readonly)
Returns the value of attribute children.
6 7 8 |
# File 'lib/wiz-teleport/group.rb', line 6 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/wiz-teleport/group.rb', line 6 def name @name end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
6 7 8 |
# File 'lib/wiz-teleport/group.rb', line 6 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
6 7 8 |
# File 'lib/wiz-teleport/group.rb', line 6 def port @port end |
#servers ⇒ Object (readonly)
Returns the value of attribute servers.
6 7 8 |
# File 'lib/wiz-teleport/group.rb', line 6 def servers @servers end |
#user ⇒ Object (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_h ⇒ Object
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 |