Skip to content

Commit

Permalink
Add Address#node
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jul 19, 2014
1 parent 80b9403 commit 0651ea5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/droonga/address.rb
Expand Up @@ -49,7 +49,7 @@ def initialize(components={})
end

def to_s
string = "#{@host}:#{@port}/#{@tag}"
string = node
string << ".#{@name}" if @name
string
end
Expand All @@ -61,5 +61,9 @@ def to_a
def ==(other)
other.is_a?(self.class) and to_a == other.to_a
end

def node
"#{@host}:#{@port}/#{@tag}"
end
end
end
7 changes: 7 additions & 0 deletions test/unit/test_address.rb
Expand Up @@ -43,4 +43,11 @@ def test_no_name
parse("192.168.0.1:2929/droonga"))
end
end

class FormatterTest < self
def test_node
assert_equal("192.168.0.1:2929/droonga",
address("192.168.0.1", 2929, "droonga", "000").node)
end
end
end

0 comments on commit 0651ea5

Please sign in to comment.