This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def take_block(number, &block) | |
block.call | |
end | |
[1, 2, 3, 4, 5].each do |number| | |
take_block number do | |
puts "Block being called in the method! #{number}" | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BadDog | |
def initialize(name) # instance method | |
@name = name # instance veriable | |
end | |
def get_name # getter method | |
@name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change_info(n, h, w) | |
self.name = n | |
self.height = h | |
self.weight = w | |
end | |
def change_info(n, h, w) | |
@name = n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Animal | |
def speak | |
"Hello!" | |
end | |
end | |
class GoodDog < Animal | |
attr_accessor :name | |
def initialize(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Drive | |
def speed_up( num ) | |
self.speed += num | |
puts "you accelerate by #{num} and are now travelling at #{speed} mph." | |
end | |
def slow_down( num ) | |
self.speed -= num | |
puts "You decrease your speed by #{num} and are now travelling at #{speed}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Drive | |
def speed_up( num ) | |
self.speed += num | |
puts "you accelerate by #{num} and are now travelling at #{speed} mph." | |
end | |
def slow_down( num ) | |
self.speed -= num | |
puts "You decrease your speed by #{num} and are now travelling at #{speed}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module VehicleAge | |
def age | |
some code.... | |
puts "Your #{VEHICLETYPE} is x years old" | |
end | |
end | |
class MyCar | |
VEHICLETYPE = "car" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Drive | |
def speed_up( num ) | |
self.speed += num | |
puts "you accelerate by #{num} and are now travelling at #{speed} mph." | |
end | |
def slow_down( num ) | |
self.speed -= num | |
puts "You decrease your speed by #{num} and are now travelling at #{speed}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(window).load(function() { | |
// The slider being synced must be initialized first | |
$('#carousel').flexslider({ | |
animation: "slide", | |
controlNav: false, | |
animationLoop: false, | |
slideshow: false, | |
itemWidth: 210, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# start new game | |
# ask players name | |
# introduce opponent from random opponents | |
# display info regarding current oponent wins/ties/losses | |
# player picks hand ( paper(p), rock(r) or scissors(s) ) | |
# opponent picks hand | |
# result | |
# play again |
OlderNewer