From 0651ea56d33534fc09a452785492669080ada0fa Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Sat, 19 Jul 2014 21:29:12 +0900 Subject: [PATCH] Add Address#node --- lib/droonga/address.rb | 6 +++++- test/unit/test_address.rb | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/droonga/address.rb b/lib/droonga/address.rb index 1e0a9450..0052f0ba 100644 --- a/lib/droonga/address.rb +++ b/lib/droonga/address.rb @@ -49,7 +49,7 @@ def initialize(components={}) end def to_s - string = "#{@host}:#{@port}/#{@tag}" + string = node string << ".#{@name}" if @name string end @@ -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 diff --git a/test/unit/test_address.rb b/test/unit/test_address.rb index 6d118fa9..6f63a914 100644 --- a/test/unit/test_address.rb +++ b/test/unit/test_address.rb @@ -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