Class: Bard::SSHServer
- Inherits:
-
Object
- Object
- Bard::SSHServer
- Defined in:
- lib/bard/plugins/ssh/server.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#gateway ⇒ Object
readonly
Returns the value of attribute gateway.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#ssh_key ⇒ Object
readonly
Returns the value of attribute ssh_key.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #connection_string ⇒ Object
- #hash ⇒ Object
- #hostname ⇒ Object
-
#initialize(uri_string, **options) ⇒ SSHServer
constructor
A new instance of SSHServer.
- #ssh_uri ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(uri_string, **options) ⇒ SSHServer
Returns a new instance of SSHServer.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bard/plugins/ssh/server.rb', line 7 def initialize(uri_string, **) @uri_string = uri_string @options = uri = parse_uri(uri_string) @user = uri.user || ENV['USER'] @host = uri.host @port = uri.port ? uri.port.to_s : "22" @path = [:path] @gateway = [:gateway] @ssh_key = [:ssh_key] @env = [:env] end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
5 6 7 |
# File 'lib/bard/plugins/ssh/server.rb', line 5 def env @env end |
#gateway ⇒ Object (readonly)
Returns the value of attribute gateway.
5 6 7 |
# File 'lib/bard/plugins/ssh/server.rb', line 5 def gateway @gateway end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/bard/plugins/ssh/server.rb', line 5 def host @host end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/bard/plugins/ssh/server.rb', line 5 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/bard/plugins/ssh/server.rb', line 5 def port @port end |
#ssh_key ⇒ Object (readonly)
Returns the value of attribute ssh_key.
5 6 7 |
# File 'lib/bard/plugins/ssh/server.rb', line 5 def ssh_key @ssh_key end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'lib/bard/plugins/ssh/server.rb', line 5 def user @user end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
40 41 42 43 |
# File 'lib/bard/plugins/ssh/server.rb', line 40 def ==(other) return false unless other.is_a?(Bard::SSHServer) state == other.state end |
#connection_string ⇒ Object
36 37 38 |
# File 'lib/bard/plugins/ssh/server.rb', line 36 def connection_string "#{user}@#{host}" end |
#hash ⇒ Object
46 47 48 |
# File 'lib/bard/plugins/ssh/server.rb', line 46 def hash state.hash end |
#hostname ⇒ Object
26 27 28 |
# File 'lib/bard/plugins/ssh/server.rb', line 26 def hostname host end |
#ssh_uri ⇒ Object
22 23 24 |
# File 'lib/bard/plugins/ssh/server.rb', line 22 def ssh_uri URI("ssh://#{user}@#{host}:#{port}") end |
#to_s ⇒ Object
30 31 32 33 34 |
# File 'lib/bard/plugins/ssh/server.rb', line 30 def to_s str = "#{user}@#{host}" str += ":#{port}" if port && port != "22" str end |