Skip to content

Instantly share code, notes, and snippets.

@Olefine
Created October 13, 2013 20:42
Show Gist options
  • Save Olefine/6967206 to your computer and use it in GitHub Desktop.
Save Olefine/6967206 to your computer and use it in GitHub Desktop.
require "interface"
Strategy = interface {
required_methods :use
}
class StrategyOne
implements Strategy
def use
puts "This is first case"
end
end
class StrategyTwo
implements Strategy
def use
puts "This is second case"
end
end
class Contex
attr_accessor :strategy
def initialize(strategy)
@strategy = strategy
end
def get_case
@strategy.use
end
end
contex = Contex.new(StrategyOne.new)
contex.get_case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment