Guest User

Untitled

a guest
May 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. Let say that this is a scenario
  2.  
  3. ##
  4.  
  5. @@algorithm_path = "myRoutingAlgorithm.rb"
  6.  
  7. Class Node
  8. attr_reader :message
  9. @message
  10. def add(msg)
  11. @message=msg
  12. end
  13. end
  14.  
  15. Class Router
  16. def self.route_to(from, destination)
  17. #find the next node at the path in the way to node 'destination'
  18. #if i'm alredy at node 'from'
  19. # ...
  20. return #something
  21. end
  22. end
  23.  
  24. start = Node.new
  25. a = Node.new
  26. b = Node.new
  27. c = Node.new
  28. end = Node.new
  29.  
  30. #forward the message from start to the first
  31. #hop in the way to the end
  32. Router.route_to(start, end).add(start.message)
  33.  
  34. ##
  35.  
  36. Here is the question.
  37. The user must give the path to a file where is the
  38. routing algorithm. How do I include that file and
  39. use the Router class as an interface?
  40.  
  41. This is becouse i'm coding a network routing simulator
Add Comment
Please, Sign In to add comment