Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created January 19, 2010 09:50
Show Gist options
  • Select an option

  • Save ukstudio/280813 to your computer and use it in GitHub Desktop.

Select an option

Save ukstudio/280813 to your computer and use it in GitHub Desktop.
class Button
def initialize(obj)
@is_on = true
@obj = obj
end
def poll
if @is_on
@obj.turn_off
@is_on = false
else
@obj.turn_on
@is_on = true
end
end
end
require 'switcher'
class Lamp
include Switcher
def turn_off
puts "#{self}消しました"
end
def turn_on
puts "#{self}付けました"
end
end
module Switcher
def turn_off
puts 'オフ'
end
def turn_on
puts 'オン'
end
end
require 'switcher'
class Lamp
include Switcher
def turn_off
puts "#{self}消しました"
end
def turn_on
puts "#{self}付けました"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment