Commit 3f56d409 by The Vien Pham

update Module_2_1 and add test.txt

parent a42a22d8
puts "----------------- level 1 is start -------------------------"
m = "Jimmy".reverse
puts m
......@@ -15,3 +17,81 @@ puts tru
len = "Jimmy".length
puts len
puts "Jimmy" * 5
puts "----------------- level 1 is done -------------------------"
print "\n"
puts "----------------- level 2 is start -------------------------"
/ puts 40.reverse => error/
/ to_s: convert to string
to_i: convert to integer
to_a: convert to array /
puts 40.to_s.reverse
/ array/
puts [12,47,35].max
ticket = [12,47,35].sort
puts ticket
print poem =
"My toast has flown from my hand
And my toast has gone to the moon.
But when I saw it on television,
planting out flag on Halley's comet,
More still did I want to eat it.\n"
puts poem['toast'] = 'honeydew'
print poem
puts poem.reverse
puts poem.lines.to_a.reverse
print poem.lines.to_a.reverse.join
puts poem.include? "my hand"
puts poem.downcase
puts "----------------- level 2 is done -------------------------"
print "\n"
puts "----------------- level 3 is start -------------------------"
puts ratings = Hash.new(5.times {print "ODELAY!"})
puts 5.times {print "Odelay!"}
puts Dir.entries "/"
puts File.read("/home/nhib/Desktop/my-git-repo/Ruby-Training/test.txt")
puts File.mtime("/home/nhib/Desktop/my-git-repo/Ruby-Training/test.txt")
puts "----------------- level 3 is done -------------------------"
print "\n"
puts "----------------- level 6 is start -------------------------"
def load_comics (path)
File.foreach(path) do |line|
name, url = line.split(':')
end
end
path = "/home/nhib/Desktop/my-git-repo/Ruby-Training/test.txt"
comics = load_comics(path)
Popup.make do
h1 "Things to do"
list do
p "Try out ruby"
p "Ride a tiger"
P "(down River Euphrates)"
end
end
puts "----------------- level 6 is done -------------------------"
print "\n"
vien
{"Achewood" => "http://achewood.com/",
"Disosaur comics" => "http://qwantz.com/"}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment