Created
August 17, 2010 17:52
-
-
Save davidxkr/531119 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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