Ruby From Beginning

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen

Hello World

#!/usr/bin/ruby
puts "Hello World!"

What is your name?

#!/usr/bin/ruby
print "What is your name? "
name = gets
puts  "Your name is #{name}"

Read a File

#!/usr/bin/ruby
puts "What file do you want to read? "
Filename = gets
Filename.delete!("\n")
TheFile = File.read( Filename )
puts TheFile.to_s