Skip to content

Instantly share code, notes, and snippets.

@tjackiw
Created December 19, 2012 09:46
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 tjackiw/4335614 to your computer and use it in GitHub Desktop.
Save tjackiw/4335614 to your computer and use it in GitHub Desktop.
Design Patterns: Observer Pattern in Ruby
class Car
attr_reader :mileage, :service
def initialize(mileage = 0, service = 3000)
@mileage, @service = mileage, service
end
def log(miles)
@mileage += miles
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment