From: Victor Shepelev Date: 2006-03-25T16:25:09+09:00 Subject: Re: [QUIZ] Object Query Language for Ruby? > Victor Shepelev wrote: > > Today I've stubled upon an interesting article at CodeProject: > > > > Karmencita: an object query language for .NET > > ... > > // initialize the data source > > // (in this case a Stack of Customers) > > Stack customers = ..... > > customers = ... > > > // initialize Karmencita with > > // the type of object to be queries > > ObjectQuery oq = > > new ObjectQuery(); > > > > // write the query > > string query = "Name = [Thor the Mighty]" + > > " and IsMale = true and BirthDate" + > > " < [1,1,1910]"; > > oq = proc {|cust| cust.name == "Thor the Mighty" && > cust.male? && cust.birth_date < Date.new(1910) } > > > //run the query > > Customer[] processes = (Customer[]) oq.Select(customers, query); > > processes = customers.select(&oq) > > > I have no idea about when and how can be it useful, but it can be > > intersting > > to do the trick for Ruby, ha? > > It's already there! > Hmmm... Really :) I'm not an idiot, usually. I must say, Ruby solution seems to be much prettier and "in a spirit of a languages", yes? Victor.