lib/formulae/run/excel_functions.rb in rubyfromexcel-0.0.5 vs lib/formulae/run/excel_functions.rb in rubyfromexcel-0.0.6

- old
+ new

@@ -109,9 +109,25 @@ return :na unless number.is_a?(Numeric) return :na unless decimal_places.is_a?(Numeric) number.round(decimal_places) end + def roundup(number,decimal_places) + return number if iserr(number) + return decimal_places if iserr(decimal_places) + return :na unless number.is_a?(Numeric) + return :na unless decimal_places.is_a?(Numeric) + (number * 10**decimal_places).ceil.to_f / 10**decimal_places + end + + def rounddown(number,decimal_places) + return number if iserr(number) + return decimal_places if iserr(decimal_places) + return :na unless number.is_a?(Numeric) + return :na unless decimal_places.is_a?(Numeric) + (number * 10**decimal_places).floor.to_f / 10**decimal_places + end + def sum(*args) flatten_and_inject(args) do |counter,arg| arg.is_a?(Numeric) ? counter + arg.to_f : counter end end \ No newline at end of file