module Bmg::TupleAlgebra
Public Class Methods
allbut(tuple, butlist)
click to toggle source
# File lib/bmg/support/tuple_algebra.rb, line 4 def allbut(tuple, butlist) tuple.reject{|k,v| butlist.include?(k) } end
project(tuple, attrlist)
click to toggle source
# File lib/bmg/support/tuple_algebra.rb, line 9 def project(tuple, attrlist) tuple.reject{|k,v| !attrlist.include?(k) } end
rename(tuple, renaming)
click to toggle source
# File lib/bmg/support/tuple_algebra.rb, line 14 def rename(tuple, renaming) tuple.each_with_object({}){|(k,v),m| m[renaming[k] || k] = v m } end
symbolize_keys(h)
click to toggle source
# File lib/bmg/support/tuple_algebra.rb, line 22 def symbolize_keys(h) return h if h.empty? h.each_with_object({}){|(k,v),h| h[k.to_sym] = v } end
Private Instance Methods
allbut(tuple, butlist)
click to toggle source
# File lib/bmg/support/tuple_algebra.rb, line 4 def allbut(tuple, butlist) tuple.reject{|k,v| butlist.include?(k) } end
project(tuple, attrlist)
click to toggle source
# File lib/bmg/support/tuple_algebra.rb, line 9 def project(tuple, attrlist) tuple.reject{|k,v| !attrlist.include?(k) } end
rename(tuple, renaming)
click to toggle source
# File lib/bmg/support/tuple_algebra.rb, line 14 def rename(tuple, renaming) tuple.each_with_object({}){|(k,v),m| m[renaming[k] || k] = v m } end
symbolize_keys(h)
click to toggle source
# File lib/bmg/support/tuple_algebra.rb, line 22 def symbolize_keys(h) return h if h.empty? h.each_with_object({}){|(k,v),h| h[k.to_sym] = v } end