This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
def diff(hash) | |
raise ArgumentError, 'Argument is not a Hash' unless hash.is_a? Hash | |
kkeys = [] | |
self.keys.each do |k| | |
diff = self[k].diff(hash[k]) if self[k].is_a? Hash and hash[k].is_a? Hash | |
kkeys << {k => diff} if diff and diff.size > 0 | |
end | |
diff = self.keys - hash.keys | |
kkeys << diff if diff and diff.size > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
f = número de casas decimais | |
d = separador de decimos (’,’ virgula por padrão) | |
t = separador de milhar (’.’ ponto por padrão) | |
*/ | |
String.prototype.currencyFormat = function (f, d, t) { | |
var n = (n = this.match(/\d/g)) ? n.join('').replace(/^0+/,'') : '0', f = (f) ? f : 2, d = (d) ? d : ',', t = (t) ? t : '.'; | |
if (n.length < f + 1) return '0' + d + ((n.length < f) ? new Array(f - n.length + 1).join('0') + n : n) | |
else return n.substr(0, n.length - f).split('').reverse().join('').match(/\d{1,3}/g).join(t).split('').reverse().join('') + d + n.substr(n.length - f) |
NewerOlder