PageRenderTime 27ms CodeModel.GetById 9ms app.highlight 14ms 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
 1require 'example'
 2
 3q = Example::IntQueue.new(10)
 4
 5puts "Inserting items into intQueue"
 6
 7begin
 8    0.upto(100) do |i|
 9    q.enqueue(i)
10  end
11rescue Example::FullError => e
12  puts "Maxsize is: #{e.maxsize}"
13end
14
15puts "Removing items"
16
17begin
18  loop do
19    q.dequeue()
20  end
21rescue Example::EmptyError => e
22  ## do nothing
23end
24
25q = Example::DoubleQueue.new(1000)
26
27puts "Inserting items into doubleQueue"
28
29begin
30  0.upto(100) do |i|
31    q.enqueue(i*1.5)
32  end
33rescue Example::FullError => e
34  puts "Maxsize is: #{e.maxsize}"
35end
36
37puts "Removing items"
38
39begin
40  loop do
41    q.dequeue()
42  end
43rescue Example::EmptyError => e
44  # do nothing
45end