From 50b9b41e1e8b3012c165ea6a4c383273afe37ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 2 Jun 2012 22:25:14 +0200 Subject: Particle add #set_dst! and specs --- lib/iotas/particle.rb | 6 ++++++ spec/particle_spec.rb | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/iotas/particle.rb b/lib/iotas/particle.rb index 3cb48b3..78975bf 100644 --- a/lib/iotas/particle.rb +++ b/lib/iotas/particle.rb @@ -114,6 +114,12 @@ module Iotas add_dsts d+Iotas::ACT_SEP+a end # + def set_dst! a, d + @room = @door = nil + @action = a + @dst = d + end + # def split_dst! @dst = @room = @door = @action = nil return if (n = next_dst).nil? diff --git a/spec/particle_spec.rb b/spec/particle_spec.rb index 0a7f095..a10a9f9 100644 --- a/spec/particle_spec.rb +++ b/spec/particle_spec.rb @@ -94,9 +94,18 @@ describe Iotas::Particle do lambda { p.add_dst 'action', nil }.should raise_error(NoMethodError) end # + it "routing: set_dst!" do + p = Iotas::Particle.new + d0 = Iotas::Door.new 'door0', nil + # + p.set_dst! 'action', d0 + p.action.should eql 'action' + p.dst.should be d0 + end + # it "routing: add_dst and split_dst!" do p = Iotas::Particle.new - d0 = Iotas::Door.new 'door0', nil + d0 = Iotas::Door.new 'door0', nil # p.split_dst! p.room.should be_nil -- cgit v1.1-2-g2b99