Skip to content

Instantly share code, notes, and snippets.

@Leejojo
Leejojo / Shakil the Dog
Created June 21, 2016 21:38
Shakil the Dog
x = 1
loop do
puts "What would you like to say to Shakil?"
say = gets.chomp.downcase
x = say.length
#If you pretend to be a dog and bark ("woof") at him, he will go a bit nuts and woof back at you three times, pretty loudly: "WOOF WOOF WOOF"
if say == "woof"
puts "WOOF WOOF WOOF"
# #If you explicitly use his name and tell him to stop (either "shakil stop" or "Shakil STOP!") he will not respond back with a bark (enjoy your moment of peace)
@Leejojo
Leejojo / FizzBuzz
Last active June 21, 2016 23:03
FizzBuzz
def fizzbuzz_value(i)
if i % 15 == 0
puts "FizzBuzz"
elsif i % 5 == 0
puts "Buzz"
elsif i % 3 == 0
puts "Fizz"
else
puts i
end
@Leejojo
Leejojo / irb_pry practice
Created June 21, 2016 16:03
Interactive Ruby (Practice)
vagrant [vagrant]> irb
2.3.0 :001 > def say_hi(name)
2.3.0 :002?> "Hi, #{name}"
2.3.0 :003?> end
=> :say_hi
2.3.0 :004 > say_hi("Joanna")
=> "Hi, Joanna"
2.3.0 :005 > an_array = ['Hello', 'nurse', 'and', 'world']
=> ["Hello", "nurse", "and", "world"]
2.3.0 :006 > an_array.each {|word| puts word}