[QUIZ] Object Query Language for Ruby?

V

Victor Shepelev

Hello.

Today I've stubled upon an interesting article at CodeProject:

Karmencita: an object query language for .NET
http://www.codeproject.com/csharp/Karmencita.asp

The do something like

-----
// initialize the data source
// (in this case a Stack of Customers)
Stack<Customer> customers = .....

// initialize Karmencita with
// the type of object to be queries
ObjectQuery<Customer> oq =
new ObjectQuery<Customer>();

// write the query
string query = "Name = [Thor the Mighty]" +
" and IsMale = true and BirthDate" +
" < [1,1,1910]";

//run the query
Customer[] processes = (Customer[]) oq.Select(customers, query);
-------


I have no idea about when and how can be it useful, but it can be intersting
to do the trick for Ruby, ha?

Victor.
 
D

Dave Burt

Victor said:
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<Customer> customers = .....

customers = ...
// initialize Karmencita with
// the type of object to be queries
ObjectQuery<Customer> oq =
new ObjectQuery<Customer>();

// 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!

Cheers,
Dave
 
V

Victor Shepelev

Victor said:
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<Customer> customers = .....

customers = ...
// initialize Karmencita with
// the type of object to be queries
ObjectQuery<Customer> oq =
new ObjectQuery<Customer>();

// 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.
 
R

Robert Klemme

Victor said:
Victor said:
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<Customer> customers = .....
customers = ...
// initialize Karmencita with
// the type of object to be queries
ObjectQuery<Customer> oq =
new ObjectQuery<Customer>();

// 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?

The longer I use Ruby the more apparent it seems to me that lambdas /
procs / blocks are one of the core features - if not *the* core feature
- that set it apart from P* languages and make these things so easy and
well looking (= easy to read and understand).

Kind regards

robert
 
J

James Edward Gray II

The longer I use Ruby the more apparent it seems to me that
lambdas / procs / blocks are one of the core features - if not
*the* core feature - that set it apart from P* languages and make
these things so easy and well looking (= easy to read and understand).

I so agree. When I first came to Ruby, blocks were probably my
biggest stumbling block. I got them down just enough not to think
they were weird every time I used one, but then didn't pay much
attention to them. Much later, when I wanted to move down the path
of enlightenment, I found myself back at blocks. I really believe
they are the key to great Ruby.

James Edward Gray II
 

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

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,668
Latest member
SamiraShac

Latest Threads

Top