# Object Query Language for Ruby?

**URL:** <https://www.ruby-forum.com/t/object-query-language-for-ruby/55922>\
**Category:** Ruby\
**Created:** [March 25, 2006, 8:04am UTC](https://www.ruby-forum.com/t/object-query-language-for-ruby/55922 "2006-03-25T08:04:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![victor123789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f0a364/32.png) [@victor123789](https://www.ruby-forum.com/u/victor123789)\
**Post date:** [March 25, 2006, 8:04am UTC](https://www.ruby-forum.com/t/object-query-language-for-ruby/55922/1 "2006-03-25T08:04:53Z")

</div>

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](http://www.codeproject.com/csharp/Karmencita.asp)

The do something like

* * *

// initialize the data source  
// (in this case a Stack of Customers)  
Stack 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]";

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

---

<div class="post-metadata">

**Author:** ![victor123789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f0a364/32.png) [@victor123789](https://www.ruby-forum.com/u/victor123789)\
**Post date:** [March 25, 2006, 8:18am UTC](https://www.ruby-forum.com/t/object-query-language-for-ruby/55922/2 "2006-03-25T08:18:58Z")

</div>

Victor S. 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!

Cheers,  
Dave

---

<div class="post-metadata">

**Author:** ![victor123789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f0a364/32.png) [@victor123789](https://www.ruby-forum.com/u/victor123789)\
**Post date:** [March 25, 2006, 8:25am UTC](https://www.ruby-forum.com/t/object-query-language-for-ruby/55922/3 "2006-03-25T08:25:16Z")

</div>

> oq = proc {|cust| cust.name == “Thor the Mighty” &&
> 
> 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.

---

<div class="post-metadata">

**Author:** ![victor123789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f0a364/32.png) [@victor123789](https://www.ruby-forum.com/u/victor123789)\
**Post date:** [March 25, 2006, 11:09am UTC](https://www.ruby-forum.com/t/object-query-language-for-ruby/55922/4 "2006-03-25T11:09:33Z")

</div>

Victor S. wrote:

> > > // initialize Karmencita with
> 
> 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
```

---

<div class="post-metadata">

**Author:** ![victor123789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f0a364/32.png) [@victor123789](https://www.ruby-forum.com/u/victor123789)\
**Post date:** [March 25, 2006, 5:26pm UTC](https://www.ruby-forum.com/t/object-query-language-for-ruby/55922/5 "2006-03-25T17:26:48Z")

</div>

On Mar 25, 2006, at 4:08 AM, Robert K. wrote:

> 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 G. II
