Forum: Ruby Re: Newbie ahead!: Ruby-Demo

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6087a044557d6b59ab52e7dd20f94da8?d=identicon&s=25 Peña, Botp (Guest)
on 2006-01-21 07:01
(Received via mailing list)
Meino Christian Cramer [mailto:Meino.Cramer@gmx.de] :

# can someone point me to a ruby demo-script?
#
# I want to show a friend the beauty of ruby and am myself fear if
# would try my best would acchieve the opposite of what I want.
#
# It dont need to do anything sophisticated it only should show the
# Pros of programming in ruby...


Show "Hello, world." in 3 ways.

Way 1. print hello world on screen.
code: puts "Hello, world."
audience comment: hmmmm.... ok..

Way 2. print helloworld 100 times
codeA. puts "Hello, world.\n" * 100
or
codeB. 100.times{ puts "Hello, world."}
audience comment: coool..l :-)

Way 3. print helloworld to pdf.
code: require "pdf/writer"
      pdf = PDF::Writer.new
      pdf.select_font "Times-Roman"
      100.times {pdf.text "Hello, world."}
      pdf.save_as("hello.pdf")
audience comment: ..cannot comment... audience rotfl...
This topic is locked and can not be replied to.