Class: QRPC::Locator
- Inherits:
-
Object
- Object
- QRPC::Locator
- Defined in:
- lib/qrpc/locator.rb
Overview
Resource locator.
Constant Summary collapse
- PARSER =
Parser.
/^(.+)@(.+)(?:\:(\d+))?$/
- DEFAULT_PORT =
Default port.
11300
Instance Attribute Summary collapse
-
#host ⇒ String
Contains host.
-
#port ⇒ Integer
Contains port.
-
#queue ⇒ Symbol
Contains queue name.
Class Method Summary collapse
-
.parse(string) ⇒ QRPC::Locator
Parses the locator.
Instance Method Summary collapse
-
#initialize(queue, host = "localhost", port = 11300) ⇒ Locator
constructor
Constructor.
-
#to_s ⇒ String
Converts back to string.
Constructor Details
#initialize(queue, host = "localhost", port = 11300) ⇒ Locator
Constructor.
60 61 62 63 64 |
# File 'lib/qrpc/locator.rb', line 60 def initialize(queue, host = "localhost", port = 11300) @queue = queue.to_s @host = host @port = port end |
Instance Attribute Details
#host ⇒ String
Contains host.
29 30 31 |
# File 'lib/qrpc/locator.rb', line 29 def host @host end |
#port ⇒ Integer
Contains port.
37 38 39 |
# File 'lib/qrpc/locator.rb', line 37 def port @port end |
#queue ⇒ Symbol
Contains queue name.
21 22 23 |
# File 'lib/qrpc/locator.rb', line 21 def queue @queue end |
Class Method Details
.parse(string) ⇒ QRPC::Locator
Parses the locator. Excpects form <queue>@<host>:<port>. Port is optional.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/qrpc/locator.rb', line 74 def self.parse(string) match = string.match(self::PARSER) queue = match[1] host = match[2] if match.length == 3 port = match[3] else port = self::DEFAULT_PORT end port = port.to_i ## return self::new(queue, host, port); end |
Instance Method Details
#to_s ⇒ String
Converts back to string.
98 99 100 |
# File 'lib/qrpc/locator.rb', line 98 def to_s @queue.dup << "@" << @host << ":" << @port.to_s end |