Class: Assh::Host
- Inherits:
-
Object
- Object
- Assh::Host
- Defined in:
- lib/host.rb
Constant Summary collapse
- PORT_KEY =
"Port"
- HOST_KEY =
Assh::FileProvider::HOST_KEY
- HOSTNAME_KEY =
"HostName"
- HOSTS_KEY =
Assh::FileProvider::HOSTS_KEY
- GROUP_KEY =
Assh::FileProvider::GROUP_KEY
- GROUPS_KEY =
Assh::FileProvider::GROUPS_KEY
Instance Attribute Summary collapse
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#name ⇒ Object
Returns the value of attribute name.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #address ⇒ Object
-
#initialize(params) ⇒ Host
constructor
A new instance of Host.
- #to_s ⇒ Object
- #to_ssh_config ⇒ Object
Constructor Details
#initialize(params) ⇒ Host
Returns a new instance of Host.
17 18 19 20 21 22 23 |
# File 'lib/host.rb', line 17 def initialize(params) raise 'Unexpected params type' unless params.is_a? Hash @name = params.delete(HOST_KEY) @hostname = params.delete(HOSTNAME_KEY) @port = params.delete(PORT_KEY) || 22 @params = params end |
Instance Attribute Details
#hostname ⇒ Object
Returns the value of attribute hostname.
15 16 17 |
# File 'lib/host.rb', line 15 def hostname @hostname end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/host.rb', line 15 def name @name end |
#port ⇒ Object
Returns the value of attribute port.
15 16 17 |
# File 'lib/host.rb', line 15 def port @port end |
Instance Method Details
#address ⇒ Object
25 26 27 |
# File 'lib/host.rb', line 25 def address "#{hostname}:#{port}" end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/host.rb', line 29 def to_s "#{name} - #{hostname}:#{port}" end |
#to_ssh_config ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/host.rb', line 33 def to_ssh_config f = "" f << "Host #{name}\n" f << " Hostname #{hostname}\n" f << " Port #{port}\n" @params.each do |k,v| f << " #{k} #{v}\n" end f end |