K
kiranhk
I am new to Ruby and going thro' the Pragmatic Programmer. I am using
WIN XP.
I have been developing with Java for many years..
i have few questions...
1) is there anything like environment variable classpath(java) in RUBY
by which ruby will be able to find all the scripts which it needs while
running a script. I dont want to use the -S option when running ruby. I
want to create a environment variable which ruby should use while
running a script. Also will it include zip files ??
2) I am not getting the exact difference b/n String.split and
String.scan. I think split takes a RE and so will be able to do the
same as scan..
also pls help with the following program..
require 'WordIndex.rb'
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 lookup(aWord)
@index.lookup(aWord)
end
end
class Song
def initialize(name, artist, duration)
@name = name
@artist = artist
@duration = duration
end
end
songs = SongList.new
songs.append Song.new("gone with the wind","kiran","2:34")
songs.append Song.new("test Sun","krishna","1:35")
songs.lookup("gone")
I am getting the following error when i run this..
C:/kiran/ruby/product.rb:13:in `append': undefined method `name' for
#<Song:0x28cca28> (NoMethodError)
from C:/kiran/ruby/product.rb:30
thanks
Kiran
WIN XP.
I have been developing with Java for many years..
i have few questions...
1) is there anything like environment variable classpath(java) in RUBY
by which ruby will be able to find all the scripts which it needs while
running a script. I dont want to use the -S option when running ruby. I
want to create a environment variable which ruby should use while
running a script. Also will it include zip files ??
2) I am not getting the exact difference b/n String.split and
String.scan. I think split takes a RE and so will be able to do the
same as scan..
also pls help with the following program..
require 'WordIndex.rb'
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 lookup(aWord)
@index.lookup(aWord)
end
end
class Song
def initialize(name, artist, duration)
@name = name
@artist = artist
@duration = duration
end
end
songs = SongList.new
songs.append Song.new("gone with the wind","kiran","2:34")
songs.append Song.new("test Sun","krishna","1:35")
songs.lookup("gone")
I am getting the following error when i run this..
C:/kiran/ruby/product.rb:13:in `append': undefined method `name' for
#<Song:0x28cca28> (NoMethodError)
from C:/kiran/ruby/product.rb:30
thanks
Kiran