Class: Hash
Instance Method Summary
collapse
Instance Method Details
17
18
19
20
21
22
23
|
# File 'lib/ruby_code/Hash.rb', line 17
def copy
raise StandardError.new('No "copy" method has been created for '+self.class.to_s) unless self.class.to_s == 'Hash'
return self.inject({}) do |x,(key,value)|
x[key] = value
x
end
end
|
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/ruby_code/Hash.rb', line 3
def write
line = '{'
count = 0
self.each do |x,y|
line += x.write+'=>'+y.write
count += 1
next if count == self.length
line += ','
end
line += '}'
return line
end
|