Class: CouchProxy::Node
- Inherits:
-
Object
- Object
- CouchProxy::Node
- Defined in:
- lib/couchproxy/node.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#partitions ⇒ Object
readonly
Returns the value of attribute partitions.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #any_partition ⇒ Object
- #hosts?(partition) ⇒ Boolean
-
#initialize(uri, partitions) ⇒ Node
constructor
A new instance of Node.
- #partition(num) ⇒ Object
Constructor Details
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/couchproxy/node.rb', line 5 def host @host end |
#partitions ⇒ Object (readonly)
Returns the value of attribute partitions.
5 6 7 |
# File 'lib/couchproxy/node.rb', line 5 def partitions @partitions end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/couchproxy/node.rb', line 5 def port @port end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
5 6 7 |
# File 'lib/couchproxy/node.rb', line 5 def uri @uri end |
Instance Method Details
#any_partition ⇒ Object
21 22 23 |
# File 'lib/couchproxy/node.rb', line 21 def any_partition @partitions[rand(@partitions.size)] end |
#hosts?(partition) ⇒ Boolean
13 14 15 |
# File 'lib/couchproxy/node.rb', line 13 def hosts?(partition) @partitions.any? {|p| p.num == partition } end |
#partition(num) ⇒ Object
17 18 19 |
# File 'lib/couchproxy/node.rb', line 17 def partition(num) @partitions.find {|p| p.num == num } end |