Browse files

Update friends.rb example

  • Loading branch information...
1 parent 7436607 commit 8fa19a4e31cbb5a6ff5582ba7368c884819dc5fd @lsegal committed Apr 1, 2010
Showing with 3 additions and 2 deletions.
  1. +3 −2 example/friends.rb
View
5 example/friends.rb
@@ -1,6 +1,7 @@
require File.dirname(__FILE__) + '/../lib/friend'
class Car
+ attr_reader :engine
def initialize; @engine = Engine.new end
def turn_on(key)
@@ -25,11 +26,11 @@ def engage; puts "Engine turned on!" end
car.turn_on("foo")
# But we can't enable the engine directly
-car.instance_variable_get("@engine").engage
+car.engine.engage
# Output:
# Engine turned on!
# Car turned on!
# export.rb:17:in `block in export': `engage' is not accessible outside
# Engine (NoMethodError)
-# from friends.rb:35:in `<main>'
+# from friends.rb:29:in `<main>'

0 comments on commit 8fa19a4

Please sign in to comment.