This is a multi-part message in MIME format.

------extPart_000_0000_01C09CC7.960B93E0
Content-Type: text/plain;
	charsetso-8859-1"
Content-Transfer-Encoding: 7bit

When i use DATA to access the data from within the file i get the following
error.

D:\LK\Ruby Prmg\21-2-01\ch 4\src\test.rb:113: uninitialized constant
DATA(NameError)

I am attachin the ruby file with this mail.. Please comment

------extPart_000_0000_01C09CC7.960B93E0
Content-Type: application/octet-stream;
	nameest.rb"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filenameest.rb"

class WordIndex
def initialize
@index = Hash.new(nil)
end
def index(anObject, *phrases)
phrases.each do |aPhrase|
aPhrase.scan /\w[-\w']+/ do |aWord|   # extract each word
aWord.downcase!
@index[aWord] = [] if @index[aWord].nil?
@index[aWord].push(anObject)
end
end
end
def lookup(aWord)
@index[aWord.downcase]
end
end
class Song
include Comparable
@@plays = 0
attr_reader :name, :artist, :duration
attr_writer :duration
def initialize(name, artist, duration)
@name     = name
@artist   = artist
@duration = duration
@plays    = 0
end
def to_s
"Song: #{@name}--#{@artist} (#{@duration})"
end
def name
@name
end
def artist
@artist
end
def duration
@duration
end
def duration=(newDuration)
@duration = newDuration
end
def durationInMinutes
@duration/60.0   # force floating point
end
def durationInMinutes=(value)
@duration = (value*60).to_i
end
def play
@plays += 1
@@plays += 1
"This  song: #@plays plays. Total #@@plays plays."
end
def record
"Recording..."
end
def inspect
self.to_s
end
def <=>(other)
self.duration <=> other.duration
end
end
class SongList
def initialize
@songs = Array.new
@index = WordIndex.new
end
def append(aSong)
@songs.push(aSong)
@index.index(aSong, aSong.name, aSong.artist)
self
end
def deleteFirst
@songs.shift
end
def deleteLast
@songs.pop
end
def [](key)
if key.kind_of?(Integer)
@songs[key]
else
# ...
end
end
def [](key)
if key.kind_of?(Integer)
return @songs[key]
else
for i in 0... / songs.length
return @songs[i] if key == @songs[i].name
end
end
return nil
end
def [](key)
if key.kind_of?(Integer)
result = @songs[key]
else
result = @songs.find { |aSong| key == aSong.name }
end
return result
end
def lookup(aWord)
@index.lookup(aWord)
end
def createSearch(name, params)
# ...
end
end  
songFile = DATA
songs = SongList.new

songFile.each do |line|
file, length, name, title = line.chomp.split(/\s*\|\s*/)
songs.append Song.new(title, name, length)
end
puts songs[1]
__END__
/jazz/j00132.mp3  | 3:45 | Fats     Waller     | Ain't Misbehavin'
/jazz/j00319.mp3  | 2:58 | Louis    Armstrong  | Wonderful World
/bgrass/bg0732.mp3| 4:09 | Strength in Numbers | Texas Red
-----extPart_000_0000_01C09CC7.960B93E0--