tpitale (owner)

Revisions

gist: 222596 Download_button fork
public
Public Clone URL: git://gist.github.com/222596.git
Embed All Files: show embed
not_real_union_or_intersection.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module HashUnion
  def union(hash)
    (self[:union] ||= []) << hash
    self
  end
 
  alias | union
  alias + union
end
 
module HashIntersection
  def intersection(hash)
    (self[:intersection] ||= []) << hash
    self
  end
 
  alias & intersection
end
 
def Conditions(hash)
  hash.extend(HashUnion)
  hash.extend(HashIntersection)
  hash
end
 
h = (Conditions(:hello => 1) | {:goodbye => 2} | {:ciao => 3}) & {:Sah_Yoh_Nah_Rah => 4}
 
puts h.inspect