/usr/share/doc/ruby-amqp/examples/legacy/primes-simple.rb is in ruby-amqp 0.9.5-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/usr/bin/env ruby
# encoding: utf-8
# You are probably wondering what the smeg is this example all about.
# Check examples/primes.rb, the only point of this file is to compare
# with its RPC implementation.
require "bundler"
Bundler.setup
MAX = 1000
class Fixnum
def prime?
('1' * self) !~ /^1?$|^(11+?)\1+$/
end
end
class PrimeChecker
def is_prime?(number)
number.prime?
end
end
prime_checker = PrimeChecker.new
(10_000...(10_000 + MAX)).each do |n|
prime_checker.is_prime?(n)
end
|