Class: VagrantPlugins::AVF::Model::SshInfo
- Inherits:
-
Object
- Object
- VagrantPlugins::AVF::Model::SshInfo
- Defined in:
- lib/vagrant_provider_avf/model/ssh_info.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(host:, port:, username:) ⇒ SshInfo
constructor
A new instance of SshInfo.
- #to_h ⇒ Object
Constructor Details
#initialize(host:, port:, username:) ⇒ SshInfo
Returns a new instance of SshInfo.
22 23 24 25 26 |
# File 'lib/vagrant_provider_avf/model/ssh_info.rb', line 22 def initialize(host:, port:, username:) @host = normalize_host(host) @port = normalize_port(port) @username = normalize_username(username) end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/vagrant_provider_avf/model/ssh_info.rb', line 5 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/vagrant_provider_avf/model/ssh_info.rb', line 5 def port @port end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
5 6 7 |
# File 'lib/vagrant_provider_avf/model/ssh_info.rb', line 5 def username @username end |
Class Method Details
.fetch_required(attributes, key) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/vagrant_provider_avf/model/ssh_info.rb', line 15 def self.fetch_required(attributes, key) value = attributes[key] || attributes[key.to_sym] raise ArgumentError, "#{key} is required" if value.nil? || value == "" value end |
.from_h(attributes) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/vagrant_provider_avf/model/ssh_info.rb', line 7 def self.from_h(attributes) new( host: fetch_required(attributes, "host"), port: fetch_required(attributes, "port"), username: fetch_required(attributes, "username") ) end |
Instance Method Details
#to_h ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/vagrant_provider_avf/model/ssh_info.rb', line 28 def to_h { host: @host, port: @port, username: @username } end |