Created
July 21, 2012 06:32
-
-
Save verdi327/3154848 to your computer and use it in GitHub Desktop.
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 Car | |
properties doors, rims | |
def doors=(doors) | |
self.doors = doors | |
end | |
def doors | |
self.doors | |
end | |
end | |
bray_car = Car.new | |
bray_car.doors(4) | |
"hey mike, I just got a new car." | |
"wow, that's awesome, how many doors does it have" | |
"it has #{bray_car.doors} doors" | |
"given a class, you want to be able to | |
easily set an attr and get and attr" | |
class Car | |
#these are the car's attributes | |
attr_accessor :doors, :rims, :nitros | |
def initialize(doors, rims, nitros) | |
self.doors = doors | |
self.rims = rims | |
self.nitros = nitros | |
end | |
end | |
bray_car = Car.new(4, '24in', true) | |
bray_car.nitros == true | |
bray_car.rims == '24inch' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment