Created
July 13, 2011 19:08
-
-
Save trshafer/1081064 to your computer and use it in GitHub Desktop.
Module extension within module, post class inclusion
This file contains 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 FourToedFrontFeet | |
def number_of_toes | |
4 | |
end | |
end | |
module Quadruped | |
include FourToedFrontFeet | |
def number_of_legs | |
4 | |
end | |
end | |
class Bear | |
extend Quadruped | |
end | |
puts "#{Bear.number_of_toes * Bear.number_of_legs + 2} toes" # 18 toes | |
module WalksOnAllFours | |
def walking_stance | |
"all fours" | |
end | |
end | |
module Quadruped | |
include WalksOnAllFours | |
def can_stand_on_two_legs? | |
true | |
end | |
end | |
puts Bear.can_stand_on_two_legs? # true | |
puts Bear.walking_stance # undefined method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment