lib/maths/functions.rb in maths-0.0.5 vs lib/maths/functions.rb in maths-0.0.6

- old
+ new

@@ -1,8 +1,28 @@ module Maths class Functions FUNCTIONS = { - "sqrt" => Proc.new { |val| BigDecimal.new(Math.sqrt(val).to_s) } + "sqrt" => Proc.new { |val| BigDecimal.new(Math.sqrt(val).to_s) }, + "cbrt" => Proc.new { |val| BigDecimal.new(Math.cbrt(val).to_s) }, + "sin" => Proc.new { |val| BigDecimal.new(Math.sin(val).to_s) }, + "asin" => Proc.new { |val| BigDecimal.new(Math.sin(val).to_s) }, + "sinh" => Proc.new { |val| BigDecimal.new(Math.sinh(val).to_s) }, + "asinh" => Proc.new { |val| BigDecimal.new(Math.asinh(val).to_s) }, + "cos" => Proc.new { |val| BigDecimal.new(Math.cos(val).to_s) }, + "acos" => Proc.new { |val| BigDecimal.new(Math.acos(val).to_s) }, + "cosh" => Proc.new { |val| BigDecimal.new(Math.cosh(val).to_s) }, + "acosh" => Proc.new { |val| BigDecimal.new(Math.acosh(val).to_s) }, + "tan" => Proc.new { |val| BigDecimal.new(Math.tan(val).to_s) }, + "atan" => Proc.new { |val| BigDecimal.new(Math.atan(val).to_s) }, + "tanh" => Proc.new { |val| BigDecimal.new(Math.tanh(val).to_s) }, + "atanh" => Proc.new { |val| BigDecimal.new(Math.atanh(val).to_s) }, + "ln" => Proc.new { |val| BigDecimal.new(Math.log(val).to_s) }, + "log" => Proc.new { |val| BigDecimal.new(Math.log10(val).to_s) }, + "log2" => Proc.new { |val| BigDecimal.new(Math.log2(val).to_s) }, + "floor" => Proc.new { |val| BigDecimal.new(val.floor.to_s) }, + "ceil" => Proc.new { |val| BigDecimal.new(val.ceil.to_s) }, + "ceiling" => Proc.new { |val| BigDecimal.new(val.ceil.to_s) }, + "round" => Proc.new { |val| BigDecimal.new(val.round.to_s) } } def self.exec(function, value) FUNCTIONS[function].call(value) end \ No newline at end of file