Created
October 14, 2015 21:52
-
-
Save allolex/f17b542a977e72385a0e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require_relative 'talkative' | |
class Vehicle | |
attr_accessor :engine, :tires | |
end | |
class Car < Vehicle | |
def initialize | |
@tires = 4 | |
end | |
end | |
class Motorcycle < Vehicle | |
def initialize | |
@tires = 2 | |
end | |
end | |
class TelevisionCar < Car | |
include Talkative | |
end | |
kitt = TelevisionCar.new | |
p TelevisionCar.ancestors | |
p TelevisionCar.superclass | |
kitt.speak | |
puts kitt.tires | |
# c = Car.new | |
# p Car.superclass | |
# c.engine = "small" | |
# p c.engine | |
# | |
# m = Motorcycle.new | |
# p Motorcycle.superclass | |
# m.engine = "smaller" | |
# p m.engine |
This file contains hidden or 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 Talkative | |
def speak | |
puts "hello" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment