mongo-ruby-driver/lib/mongo/node.rb

19 lines
452 B
Ruby
Raw Normal View History

2011-08-09 13:45:36 +00:00
module Mongo
class Node
attr_accessor :host, :port, :address
def initialize(data)
data = data.split(':') if data.is_a?(String)
self.host = data[0]
self.port = data[1] ? data[1].to_i : Connection::DEFAULT_PORT
self.address = "#{host}:#{port}"
end
def eql?(other)
other.is_a?(Node) && host == other.host && port == other.port
end
alias :== :eql?
def hash
address.hash
end
end
end