Class: AssLauncher::Support::ConnectionString::Server::ServerDescr
- Inherits:
-
Object
- Object
- AssLauncher::Support::ConnectionString::Server::ServerDescr
- Defined in:
- lib/ass_launcher/support/connection_string.rb
Overview
Simple class host:port
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Class Method Summary collapse
-
.parse(srv_str) ⇒ Arry<ServerDescr>
Parse sting <srv_string>.
Instance Method Summary collapse
-
#initialize(host, port = nil) ⇒ ServerDescr
constructor
A new instance of ServerDescr.
-
#to_s ⇒ String
Formated ‘host:port’.
Constructor Details
#initialize(host, port = nil) ⇒ ServerDescr
Returns a new instance of ServerDescr.
207 208 209 210 |
# File 'lib/ass_launcher/support/connection_string.rb', line 207 def initialize(host, port = nil) @host = host.strip @port = port.to_s.strip end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
203 204 205 |
# File 'lib/ass_launcher/support/connection_string.rb', line 203 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
203 204 205 |
# File 'lib/ass_launcher/support/connection_string.rb', line 203 def port @port end |
Class Method Details
.parse(srv_str) ⇒ Arry<ServerDescr>
Parse sting <srv_string>
215 216 217 218 219 220 221 222 |
# File 'lib/ass_launcher/support/connection_string.rb', line 215 def self.parse(srv_str) r = [] srv_str.split(',').each do |srv| srv.strip! r << new(* srv.chomp.split(':')) unless srv.empty? end r end |
Instance Method Details
#to_s ⇒ String
Returns formated ‘host:port’.
225 226 227 |
# File 'lib/ass_launcher/support/connection_string.rb', line 225 def to_s "#{host}" + (port.empty? ? '' : ":#{port}") end |