Skip to content

Instantly share code, notes, and snippets.

@allolex
Created October 14, 2015 21:52
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 allolex/f17b542a977e72385a0e to your computer and use it in GitHub Desktop.
Save allolex/f17b542a977e72385a0e to your computer and use it in GitHub Desktop.
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
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