I am new to Ruby and am trying to run a piece of code from Programming
Ruby in cmd. When i run in cmd >ruby Song.rb, I don't get any output.
But I can get the result I expected when I run in irb. Can anyone help
me on this?
class Song
def initialize(name , artist, duartion)
@name = name
@artist = artist
@duration = duartion
end
def to_s
"Song: #{system @name}--#{@artist} (#{@duration})"
end
def name
@name
end
def artist
@artist
end
def duration
@duration
end
end
aSong = Song.new("NAF", "AS", 300)
aSong.to_s
aSong.artist
aSong.name
aSong.duration
--
Posted via http://www.ruby-forum.com/.