tbmx 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tbmx.rb +22 -2
- metadata +2 -2
data/lib/tbmx.rb
CHANGED
@@ -294,8 +294,24 @@ module TBMX
|
|
294
294
|
"#{Math::PI}"
|
295
295
|
when "e"
|
296
296
|
"#{Math::E}"
|
297
|
-
when "+"
|
298
|
-
|
297
|
+
when "+"
|
298
|
+
injectable_math_function_handler 0, :+
|
299
|
+
when "-"
|
300
|
+
if (numbers = numbers_from_expressions).length == 1
|
301
|
+
injectable_math_function_handler 0, :-
|
302
|
+
else
|
303
|
+
reducable_math_function_handler :-
|
304
|
+
end
|
305
|
+
when "*"
|
306
|
+
injectable_math_function_handler 1, :*
|
307
|
+
when "/"
|
308
|
+
if (numbers = numbers_from_expressions).length == 1
|
309
|
+
1 / numbers.first
|
310
|
+
else
|
311
|
+
reducable_math_function_handler :/
|
312
|
+
end
|
313
|
+
when "%"
|
314
|
+
injectable_math_function_handler numbers_from_expressions.first, :%
|
299
315
|
when "^", "**"
|
300
316
|
number, exponent = numbers_from_expressions
|
301
317
|
number.send :**, exponent
|
@@ -344,6 +360,10 @@ module TBMX
|
|
344
360
|
end.reject &:nil?
|
345
361
|
end
|
346
362
|
|
363
|
+
def injectable_math_function_handler(initial, function)
|
364
|
+
numbers_from_expressions.inject initial, function
|
365
|
+
end
|
366
|
+
|
347
367
|
def reducable_math_function_handler(function)
|
348
368
|
numbers_from_expressions.reduce function
|
349
369
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tbmx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|