On 17/08/05, Peter Fitzgibbons <Peter.Fitzgibbons / lakewoodhomes.net> wrote:
> Hi.  Thanks Why and 'captn.
> 
> If I wanted to include the array A as a class-accessor, how would I
> extend the three def's to the variable?
> 
> IE:
> 
> class GridMaster
>   attr_accessor :grid
> 
>   def create_grid
>     @grid = [ ... ]
>   end
> End
> 
> Irb>gm = GridMaster.new
> Irb>gm.create_grid
> Irb>gm.grid.row(1)
> ???
> 
> 

Just extend Array with the functions

class Array
 def row i
   at i-1
 end

 ...
end

gm = GridMaster.new
gm.create_grid
gm.grid.row(1)

though I'm quite shure that this design is not very good. Maybe for a
start put create_grid into the initialize method

class GridMaster
  def initialize
    self.create_grid
  end
end

gm = GridMaster.new
gm.grid.row(1)

but I don't know what you want to achieve, so take this hint just as
an uninformed hint

regards,

Brian
-- 
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/