module RubyRunJs::JsMathMethods
Public Class Methods
constructor_abs(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 22 def constructor_abs(builtin, this, x) x = to_number(x) x.abs end
constructor_acos(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 27 def constructor_acos(builtin, this, x) x = to_number(x) begin return Math.acos(x) rescue return Float::NAN end end
constructor_asin(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 36 def constructor_asin(builtin, this, x) x = to_number(x) begin return Math.asin(x) rescue return Float::NAN end end
constructor_atan(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 45 def constructor_atan(builtin, this, x) x = to_number(x) begin return Math.atan(x) rescue return Float::NAN end end
constructor_atan2(builtin, this, y, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 54 def constructor_atan2(builtin, this, y, x) x = to_number(x) y = to_number(y) if x.nan? || y.nan? return Float::NAN end Math.atan2(y, x) end
constructor_ceil(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 64 def constructor_ceil(builtin, this, x) x = to_number(x) return x unless x.finite? x.ceil.to_f end
constructor_cos(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 70 def constructor_cos(builtin, this, x) x = to_number(x) Math.cos(x) end
constructor_exp(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 75 def constructor_exp(builtin, this, x) x = to_number(x) return x if x.nan? Math.exp(x) end
constructor_floor(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 81 def constructor_floor(builtin, this, x) x = to_number(x) return x unless x.finite? x.floor.to_f end
constructor_log(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 87 def constructor_log(builtin, this, x) x = to_number(x) return x if x.nan? return Float::NAN if x < 0 Math.log(x) end
constructor_max(builtin, this, *args)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 94 def constructor_max(builtin, this, *args) return -Float::INFINITY if args.length == 0 args = args.map { |i| to_number(i) } return Float::NAN if args.any?(&:nan?) args.max end
constructor_min(builtin, this, *args)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 101 def constructor_min(builtin, this, *args) return Float::INFINITY if args.length == 0 args = args.map { |i| to_number(i) } return Float::NAN if args.any?(&:nan?) args.min end
constructor_pow(builtin, this, x, y)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 108 def constructor_pow(builtin, this, x, y) x = to_number(x) y = to_number(y) x ** y end
constructor_random(builtin, this)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 114 def constructor_random(builtin, this) Random.rand end
constructor_round(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 118 def constructor_round(builtin, this, x) x = to_number(x) return x unless x.finite? x.round.to_f end
constructor_sin(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 124 def constructor_sin(builtin, this, x) x = to_number(x) Math.sin(x) end
constructor_sqrt(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 129 def constructor_sqrt(builtin, this, x) x = to_number(x) return Float::NAN if x < 0 Math.sqrt(x) end
constructor_tan(builtin, this, x)
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 135 def constructor_tan(builtin, this, x) x = to_number(x) Math.tan(x) end
property_values()
click to toggle source
# File lib/ruby_run_js/object_methods/js_math.rb, line 9 def property_values { 'E' => 2.7182818284590452354, 'LN10' => 2.302585092994046, 'LN2' => 0.6931471805599453, 'LOG2E' => 1.4426950408889634, 'LOG10E' => 0.4342944819032518, 'PI' => 3.1415926535897932, 'SQRT1_2' => 0.7071067811865476, 'SQRT2' => 1.4142135623730951 } end