Skip to content

Instantly share code, notes, and snippets.

@verdi327
Created July 21, 2012 06:32
Show Gist options
  • Save verdi327/3154848 to your computer and use it in GitHub Desktop.
Save verdi327/3154848 to your computer and use it in GitHub Desktop.
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