Skip to content

Instantly share code, notes, and snippets.

@anteaya
Forked from Whoops/output
Created January 24, 2011 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anteaya/794198 to your computer and use it in GitHub Desktop.
Save anteaya/794198 to your computer and use it in GitHub Desktop.
20 drive_vehicle(Car.new)
21 drive_vehicle(Truck.new)
7 class Car < Vehicle
10 class Truck < Vehicle
16 def drive_vehicle(v)
17 v.drive
18 end
1 C:\Users\walton.hoops\Desktop>ruby vehicle.rb
2 Cruisin in my Car
3 Cruisin in my Truck
4 Tow that gosh durn Car
5
6 C:\Users\walton.hoops\Desktop>
2 Cruisin in my Car
3 Cruisin in my Truck
1 C:\Users\walton.hoops\Desktop>ruby vehicle.rb
2 Cruisin in my Car
3 Cruisin in my Truck
4 get a long little doggie!
5 Tow that gosh durn Car
6
7 C:\Users\walton.hoops\Desktop>
3 puts "Cruisin in my #{self.class}"
1 class Vehicle
2 def drive
3 puts "Cruisin in my #{self.class}"
4 end
5 end
1 class Vehicle
2 def drive
3 puts "Cruisin in my #{self.class}"
4 end
5 end
6
7 class Car < Vehicle
8 end
9
10 class Truck < Vehicle
11 def tow(target)
12 puts "Tow that gosh durn #{target.class}"
13 end
14 end
15
16 def drive_vehicle(v)
17 v.drive
18 end
19
20 drive_vehicle(Car.new)
21 drive_vehicle(Truck.new)
22
23 Truck.new.tow(Car.new)
1 class Vehicle
2 def drive
3 puts "Cruisin in my #{self.class}"
4 end
5 end
6
7 class Car < Vehicle
8 end
9
10 class Truck < Vehicle
11 def tow(target)
12 puts "Tow that gosh durn #{target.class}"
13 end
14 end
15
16 class Cattle
17 def self.drive
18 puts "get a long little doggie!"
19 end
20 end
21
22 def drive_vehicle(v)
23 v.drive
24 end
25
26 drive_vehicle(Car.new)
27 drive_vehicle(Truck.new)
28 drive_vehicle(Cattle)
29
30 Truck.new.tow(Car.new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment