Sha256: 072ae19c952e2c4932956803fdb29a24a82483f13d93d10e5656caad3e8d03a0

Contents?: true

Size: 631 Bytes

Versions: 34

Compression:

Stored size: 631 Bytes

Contents

module Bmg
  module TupleAlgebra

    def allbut(tuple, butlist)
      tuple.reject{|k,v| butlist.include?(k) }
    end
    module_function :allbut

    def project(tuple, attrlist)
      tuple.reject{|k,v| !attrlist.include?(k) }
    end
    module_function :project

    def rename(tuple, renaming)
      tuple.each_with_object({}){|(k,v),m|
        m[renaming[k] || k] = v
        m
      }
    end
    module_function :rename

    def symbolize_keys(h)
      return h if h.empty?
      h.each_with_object({}){|(k,v),h| h[k.to_sym] = v }
    end
    module_function :symbolize_keys

  end # module TupleAlgebra
end # module Bmg

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
bmg-0.18.13 lib/bmg/support/tuple_algebra.rb
bmg-0.18.12 lib/bmg/support/tuple_algebra.rb
bmg-0.18.11 lib/bmg/support/tuple_algebra.rb
bmg-0.18.10 lib/bmg/support/tuple_algebra.rb
bmg-0.18.9 lib/bmg/support/tuple_algebra.rb
bmg-0.18.8 lib/bmg/support/tuple_algebra.rb
bmg-0.18.7 lib/bmg/support/tuple_algebra.rb
bmg-0.18.6 lib/bmg/support/tuple_algebra.rb
bmg-0.18.5 lib/bmg/support/tuple_algebra.rb
bmg-0.18.4 lib/bmg/support/tuple_algebra.rb
bmg-0.18.3 lib/bmg/support/tuple_algebra.rb
bmg-0.18.2 lib/bmg/support/tuple_algebra.rb
bmg-0.18.1 lib/bmg/support/tuple_algebra.rb
bmg-0.18.0 lib/bmg/support/tuple_algebra.rb