if ARGV.length
table1.rb
#!/usr/bin/env ruby
if ARGV.length < 1
   puts "usage: #{$0} number."
   exit -1
end
 
num = ARGV[0].to_i
 
1.upto(10) do |count|
   #  puts "#{num} x #{count} = #{num * count}"
   puts "%3d x %2d = %4d" % [num, count, num*count]  
end
 
(1..10).each do |count|
   puts "%3d x %2d = %4d" % [num, count, num*count]  
end

taint-test.rb
a = "Test string..."
a.taint
 
puts a
a << "new value" unless a.tainted?
 
puts a
 
 

test-equal.rb
a = "John"
b = "John"
c = a
 
puts "a -> b: Same..." if a.equal? b
puts "c -> a: Same..." if c.equal? a
puts "c -> b: Same..." if c.equal? b
 

to_methods.rb
#!/usr/bin/env ruby
# Print all methods starting with to_* from a class.
 
puts File.methods.select {|m| m.start_with? "to_" }.join "\n"
 

yield-test.rb
#!/usr/bin/env ruby
 
def foo
    yield
    yield
end
 
foo do
    puts "Hello"
end
 
 
 

yield2.rb
#!/usr/bin/env ruby
 
def count10
    yield "Hello"
    yield 10
    yield "Test String"
    yield "Hi"
end
 
count10 do |x|
    puts x
end
 
 
 

- See more at: http://www.chandrashekar.info/vault/ruby-scripts/simple.html#sthash.E4LdXgyV.dpuf