README.md in axiom-0.1.0 vs README.md in axiom-0.1.1

- old
+ new

@@ -13,66 +13,43 @@ [travis]: https://travis-ci.org/dkubb/axiom [gemnasium]: https://gemnasium.com/dkubb/axiom [codeclimate]: https://codeclimate.com/github/dkubb/axiom [coveralls]: https://coveralls.io/r/dkubb/axiom -Installation ------------- +Examples +-------- -With Rubygems: - -```bash -$ gem install axiom -$ irb -rubygems ->> require 'axiom' -=> true -``` - -With git and local working copy: - -```bash -$ git clone git://github.com/dkubb/axiom.git -$ cd axiom -$ rake install -$ irb -rubygems ->> require 'axiom' -=> true -``` - -Usage ------ - ```ruby relation = Axiom::Relation.new( - [ [ :id, String ], [ :name, String ], [ :color, String ], [ :weight, Float ], [ :city, String ] ], + [[:id, String], [:name, String], [:color, String], [:weight, Float], [:city, String]], [ - [ 'P1', 'Nut', 'Red', 12.0, 'London' ], - [ 'P2', 'Bolt', 'Green', 17.0, 'Paris' ], - [ 'P3', 'Screw', 'Blue', 17.0, 'Oslo' ], - [ 'P4', 'Screw', 'Red', 14.0, 'London' ], - [ 'P5', 'Cam', 'Blue', 12.0, 'Paris' ], - [ 'P6', 'Cog', 'Red', 19.0, 'London' ], - ] + ['P1', 'Nut', 'Red', 12.0, 'London'], + ['P2', 'Bolt', 'Green', 17.0, 'Paris' ], + ['P3', 'Screw', 'Blue', 17.0, 'Oslo' ], + ['P4', 'Screw', 'Red', 14.0, 'London'], + ['P5', 'Cam', 'Blue', 12.0, 'Paris' ], + ['P6', 'Cog', 'Red', 19.0, 'London'], + ] ) # Relational Operators # -------------------- # projection -new_relation = relation.project([ :id ]) +new_relation = relation.project([:id]) # removal -new_relation = relation.remove([ :name ]) +new_relation = relation.remove([:name]) # rename new_relation = relation.rename(id: :other_id, name: :other_name) # restriction new_relation = relation.restrict { |r| r.name.eq('Screw').or(r.city.eq('London')) } new_relation = relation.restrict(relation.name.eq('Screw')) new_relation = relation.restrict(name: 'Screw') -new_relation = relation.restrict([ [ :name, 'Screw' ] ]) +new_relation = relation.restrict([[:name, 'Screw']]) # natural join new_relation = relation.join(other) # OR relation + other # product @@ -95,24 +72,27 @@ # extend new_relation = relation.extend { |r| r.add(:pounds, r.weight * 2.2) } new_relation = relation.extend { |r| r.add(:pounds) { |t| t[:weight] * 2.2 } } # summarize -new_relation = relation.summarize(relation.project([ :city ])) { |r| r.add(:count, r.id.count) } -new_relation = relation.summarize(relation.project([ :city ])) { |r| r.add(:count) { |acc, t| acc.to_i + 1 } } +new_relation = relation.summarize(relation.project([:city])) { |r| r.add(:count, r.id.count) } +new_relation = relation.summarize(relation.project([:city])) { |r| r.add(:count) { |acc, t| acc.to_i + 1 } } # Non-Relational Operators # ------------------------ # returns a set that represents the relation header header = relation.header # a relation is Enumerable relation = relation.each { |tuple| ... } +# order by attributes in the header +ordered = relation.sort + # order by attribute and direction -ordered = relation.sort_by { |r| [ r.city.desc, r.name, r.color, r.id, r.weight ] } +ordered = relation.sort_by { |r| [r.city.desc, r.name, r.color, r.id, r.weight] } # reverse the relation (only allowed if ordered) new_relation = ordered.reverse # offset (only allowed if ordered) @@ -129,9 +109,10 @@ new_relation = ordered.last # default is 1 new_relation = ordered.last(5) # get a tuple from a relation containing exactly one tuple tuple = relation.one +tuple = relation.one { ... } # Updatable Views # --------------- # add a set to a relation variable