Class: Hash
- Inherits:
-
Object
show all
- Defined in:
- lib/id3.rb,
lib/invert_hash.rb
Overview
overwrite Hash.invert method
Instance Method Summary
collapse
Instance Method Details
#inverse ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/invert_hash.rb', line 71
def inverse
i = Hash.new
self.each_pair{ |k,v|
if (v.class == Array)
v.each{ |x|
if i.has_key?(x)
i[x] = [k,i[x]].flatten
else
i[x] = k
end
}
else
if i.has_key?(v)
i[v] = [k,i[v]].flatten
else
i[v] = k
end
end
}
return i
end
|
#invert ⇒ Object
95
96
97
|
# File 'lib/id3.rb', line 95
def invert
self.inverse
end
|
#old_invert ⇒ Object
93
|
# File 'lib/id3.rb', line 93
alias old_invert invert
|