Class: Sunzi::Endpoint
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(input) ⇒ Endpoint
constructor
A new instance of Endpoint.
Constructor Details
#initialize(input) ⇒ Endpoint
Returns a new instance of Endpoint.
7 8 9 10 11 12 13 14 15 |
# File 'lib/sunzi/endpoint.rb', line 7 def initialize(input) input.match(/(.*@)?(.*?)(:.*)?$/) # Load ssh config if it exists ssh = Net::SSH::Config.for($2) @user = $1 && $1.delete('@') || ssh[:user] || 'root' @host = ssh[:host_name] || $2 @port = $3 && $3.delete(':') || ssh[:port] && ssh[:port].to_s || '22' end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/sunzi/endpoint.rb', line 5 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/sunzi/endpoint.rb', line 5 def port @port end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'lib/sunzi/endpoint.rb', line 5 def user @user end |