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
a39e979e
Commit
a39e979e
authored
Dec 04, 2015
by
The Vien Pham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addModule_2_3
parent
3f56d409
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
10 deletions
+166
-10
Module_2_1.rb
+4
-10
Module_2_3.rb
+162
-0
No files found.
Module_2_1.rb
View file @
a39e979e
...
@@ -83,15 +83,9 @@ end
...
@@ -83,15 +83,9 @@ end
path
=
"/home/nhib/Desktop/my-git-repo/Ruby-Training/test.txt"
path
=
"/home/nhib/Desktop/my-git-repo/Ruby-Training/test.txt"
comics
=
load_comics
(
path
)
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 -------------------------"
puts
"----------------- level 6 is done -------------------------"
print
"
\n
"
print
"
\n
"
string_array
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
]
puts
string_array
[
4
]
Module_2_3.rb
0 → 100644
View file @
a39e979e
#Exercise UNIT 1: INTRODUCTION TO RUBY
=begin
rescue Exception => e
end
puts my_num = 25
puts my_boolean = "Check false or true? wtf"
puts my_string = "My name is bla bla..."
print "What's is your name: "
first_name = gets.chomp
print "What's is last name: "
last_name = gets.chomp
puts "Your name is #{first_name} #{last_name}"
my_dog = "Haha"
puts "I took #{my_dog} to the zoo"
=end
#UNIT 2: CONTROL FLOW IN RUBY
print
"Integer input please: "
user_enum
=
Integer
(
gets
.
chomp
)
if
user_enum
<
0
puts
"You picked a negative Integer"
elsif
user_enum
>
0
puts
"You picked a positive Integer"
else
puts
"You picked zero"
end
if
1
>
2
puts
"right"
else
puts
"wtf?!"
end
# boolean_1 = (3 < 4 || false) && (false || true)
boolean_1
=
true
# boolean_2 = !true && (!true || 100 != 5**2)
boolean_2
=
false
# boolean_3 = true || !(true || false)
boolean_3
=
true
problem
=
false
puts
"GOod to go"
unless
problem
=begin
print "What's you want to input this here my user: "
user_input = gets.chomp
user_input.downcase!
if user_input.include? "s"
user_input.gsub!(/s/,"th")
else
puts "Not have S in your string"
end
puts "Actually input above: " + "#{user_input}!"
=end
=begin
i = 0
while i < 5
puts i
i = i + 1
end
=end
=begin
j = 0
until j == 5
j += 1
end
puts j
=end
#for
=begin
for num in 1..15
puts num
end
=end
#The loop method
=begin
i = 0
loop do
i += 1
print "#{i}"
break if i > 5
end
=end
=begin
odds = [1,3,5,7,9]
odds.each do |x|
x *= 2
puts x
end
=end
10
.
times
{
print
"chunky bacon!"
}
=begin
m = 0
loop do
m += 1
print "RUBY!"
break if m == 30
end
=end
=begin
puts "Text to search through: "
text = gets.chomp
puts "Word to redact: "
redact = gets.chomp
words = text.split(" ")
words.each do |word|
if word != redact
print word + " "
else
print "REACTED"
end
end
my_2d_array = [["string",false,"125"],[true,"string","50"],["102","vien","pham"]]
my_2d_array.each do |x|
print "#{x}\n"
end
=end
lunch_order
=
{
"Ryan"
=>
"wonton soup"
,
"Eric"
=>
"hamburger"
,
"Jimmy"
=>
"sandwich"
,
"Sasha"
=>
"salad"
,
"Cole"
=>
"taco"
}
lunch_order
.
each
do
|
x
,
y
|
puts
"
#{
x
}
"
+
"
#{}
"
end
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