PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/ruby/exception_class/runme.rb

#
Ruby | 45 lines | 33 code | 10 blank | 2 comment | 0 complexity | 46afdd903639076d3fdc97cd232500bb MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. require 'example'
  2. q = Example::IntQueue.new(10)
  3. puts "Inserting items into intQueue"
  4. begin
  5. 0.upto(100) do |i|
  6. q.enqueue(i)
  7. end
  8. rescue Example::FullError => e
  9. puts "Maxsize is: #{e.maxsize}"
  10. end
  11. puts "Removing items"
  12. begin
  13. loop do
  14. q.dequeue()
  15. end
  16. rescue Example::EmptyError => e
  17. ## do nothing
  18. end
  19. q = Example::DoubleQueue.new(1000)
  20. puts "Inserting items into doubleQueue"
  21. begin
  22. 0.upto(100) do |i|
  23. q.enqueue(i*1.5)
  24. end
  25. rescue Example::FullError => e
  26. puts "Maxsize is: #{e.maxsize}"
  27. end
  28. puts "Removing items"
  29. begin
  30. loop do
  31. q.dequeue()
  32. end
  33. rescue Example::EmptyError => e
  34. # do nothing
  35. end