Skip to content

Instantly share code, notes, and snippets.

Created January 30, 2010 23:37
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 anonymous/290785 to your computer and use it in GitHub Desktop.
Save anonymous/290785 to your computer and use it in GitHub Desktop.
module Earth
module Gravity
module Oxygen
class AlienSpecies
def what_am_i
puts "I'm an Alien Species that crashed landed on Earth. I'm bound by gravity, and forced to breathe oxygen."
end
end
end
end
module Oxygen
class AlienSpecies
def what_am_i
puts "I'm an Alien Species that crashed landed on Earth, and I'm forced to breathe oxygen."
end
end
end
class AlienSpecies
def what_am_i
puts "I'm an Alien Species that crashed landed on Earth."
end
end
def what_am_i
puts "I'm inside the earth and free"
end
end
class ClassThatIncludes
include Earth
end
class ClassThatExtends
extend Earth
end
x = Earth::Gravity::Oxygen::AlienSpecies.new
x.what_am_i
y = Earth::Oxygen::AlienSpecies.new
y.what_am_i
z = Earth::AlienSpecies.new
z.what_am_i
puts "Module Include Example 1"
ClassThatIncludes.new.what_am_i
puts "Module Extend Example 1"
ClassThatExtends.what_am_i
puts "Module Include Example 2"
ClassThatIncludes::Gravity::Oxygen::AlienSpecies.new.what_am_i
puts "Module Extend Example 2"
puts "I can't extend into any other module and class."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment