Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
Ruby-Training
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
The Vien Pham
Ruby-Training
Commits
3f56d409
Commit
3f56d409
authored
Dec 03, 2015
by
The Vien Pham
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update Module_2_1 and add test.txt
parent
a42a22d8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
Module_2_1.rb
+80
-0
test.txt
+5
-0
No files found.
Module_2_1.rb
View file @
3f56d409
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
"
test.txt
0 → 100644
View file @
3f56d409
vien
{"Achewood" => "http://achewood.com/",
"Disosaur comics" => "http://qwantz.com/"}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment