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.
215 216 217 218 |
# File 'lib/ass_launcher/support/connection_string.rb', line 215 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.
211 212 213 |
# File 'lib/ass_launcher/support/connection_string.rb', line 211 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
211 212 213 |
# File 'lib/ass_launcher/support/connection_string.rb', line 211 def port @port end |
Class Method Details
.parse(srv_str) ⇒ Arry<ServerDescr>
Parse sting <srv_string>
223 224 225 226 227 228 229 230 |
# File 'lib/ass_launcher/support/connection_string.rb', line 223 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’.
233 234 235 |
# File 'lib/ass_launcher/support/connection_string.rb', line 233 def to_s "#{host}" + (port.empty? ? '' : ":#{port}") end |