Spreadsheet development

A

Ahmed Abdelsalam

Hi,...

I'd like to create a Spreadsheet model, where I can access cells like
the following:

sheet = Spreadsheet.new
sheet.cells.a1 = 'Hello'
sheet.cells.b3 = 'World'

The problem is in how to define cell names to be accessed in the above
manner?

Any help?

Thanks

Ahmed
 
M

Martin DeMello

Hi,...

I'd like to create a Spreadsheet model, where I can access cells like
the following:

sheet = Spreadsheet.new
sheet.cells.a1 = 'Hello'
sheet.cells.b3 = 'World'

The problem is in how to define cell names to be accessed in the above
manner?

Any help?

method_missing should do it

irb(main):001:0> class Cells
irb(main):002:1> def method_missing(meth, *args)
irb(main):003:2> print "you tried to access cell #{meth}"
irb(main):004:2> end
irb(main):005:1> end
irb(main):006:0> cells = Cells.new
irb(main):007:0> cells.a1
you tried to access cell a1

martin
 
A

Ahmed Abdelsalam

Martin said:
method_missing should do it

irb(main):001:0> class Cells
irb(main):002:1> def method_missing(meth, *args)
irb(main):003:2> print "you tried to access cell #{meth}"
irb(main):004:2> end
irb(main):005:1> end
irb(main):006:0> cells = Cells.new
irb(main):007:0> cells.a1
you tried to access cell a1

martin

Thanks martin for your response. I've tried it with ruby and it's OK.
Actually my objective is to run it with JRuby, but the same code is
giving error:
at (unknown).(unknown)(Unknown Source)
at #<Class:01x114025>.method_missing(<unknown>:1)
at (unknown).(unknown):)1)

Any suggestion?

Regards,..

Ahmed
 
M

Mark Thomas

Thanks martin for your response. I've tried it with ruby and it's OK.
Actually my objective is to run it with JRuby, but the same code is
giving error:
at (unknown).(unknown)(Unknown Source)
  at #<Class:01x114025>.method_missing(<unknown>:1)
  at (unknown).(unknown):)1)

Any suggestion?

Upgrade? There were problems with method_missing in older versions of
JRuby. I don't know what version you're using, but I would suggest
1.2.

-- Mark.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,491
Latest member
mohitk

Latest Threads

Top