Chair
Me: What's the first thing you think of when I say 'Tables'?
J: 'Chair'.
Chair is a simple Table class for Ruby, with an associated Row class.
Installation
Add this line to your application's Gemfile:
gem 'chairs'
And then execute:
$ bundle
Or install it yourself as:
$ gem install chairs
Usage
>> require 'chairs'
=> true
>> t = Table.new :title
=> #<Table:0x0000000162ee08>
>> t.set_primary_key! :title
=> :title
>> t.insert! title: 'Looking for Alaska'
=> #<Row:0x007feb28035be0>
>> t.find_by_title('Looking for Alaska')
>> ["Looking for Alaska"]
>> t.add_column! :author
=> true
>> t.insert! title: 'An Abundance of Katherines', author: 'John Green'
=> #<Row>
>> t.add_index! :author
=> true
>> t.find_by_title('Looking for Alaska')[:author] = 'John Green'
=> 'John Green'
>> t.find_by_author('John Green').to_a
=> ["An Abundance of Katherines", "John Green"]
>> t.find_by_title('An Abundance of Katherines')[:author] = 'John Green'
=> "John Green"
>> r = t.where_author_is 'John Green'
=> [#<Row>, #<Row>]
>> r.map {|r| r.to_a}
=> [["An Abundance of Katherines", "John Green"], ["Looking for Alaska", "John Green"]]
Contributing
- Fork it ( https://github.com/toroidal-code/chairs/fork )
- Create your feature branch (
git checkout -b features/my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin features/my-new-feature
) - Create a new Pull Request