Skip to content

Instantly share code, notes, and snippets.

@davidxkr
Created August 17, 2010 17:52
Show Gist options
  • Save davidxkr/531119 to your computer and use it in GitHub Desktop.
Save davidxkr/531119 to your computer and use it in GitHub Desktop.
class SM1
def initialize
file = File.exists?('dev.log') ? File.open('dev.log', 'a') : File.new('dev.log', 'a')
file << 'Just creating ' + self.class.to_s + "\n"
end
end
class SM2
def initialize
@file = File.open('dev.log', 'a')
@file << 'Just creating ' + self.class.to_s + "\n"
end
def say_hi
puts 'Hi somebody'
@file << "Just said hi\n"
end
end
class SM3
def to_str
file = File.open('dev.log', 'a')
msg = "I'm a #{self.class.to_s} hell yeah"
file << msg
msg
end
end
sm1 = SM1.new
sm2 = SM2.new
sm2.say_hi
sm3 = SM3.new
p sm3.to_str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment