Skip to content

Instantly share code, notes, and snippets.

@tjackiw
Created December 19, 2012 09:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tjackiw/4335615 to your computer and use it in GitHub Desktop.
Design Patterns: Observer Pattern in Ruby
class Notifier
def update(car, miles)
puts "The car has logged #{miles} miles, totaling #{car.mileage} miles traveled."
puts "The car needs to be taken in for a service!" if car.service <= car.mileage
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment