calculator7 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/calculator7.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40211eb9c733da716a3293644f7f37e2eb0359e8
|
4
|
+
data.tar.gz: 872356cfed078745997a82ffb418481df99c9fa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07d5e9632568fdda114290d5656eefe6ec2afabe2774390c0e3589ebdd48bd1f10abf68be4652f68d9ce42d1779ceeb896efa2cb270f720e4238d70e9936ff02
|
7
|
+
data.tar.gz: fd3d2c5c2489157322055b1daaab184fd7c963ae5b50c19c65ad066d495ddab6c4899d489b955d28b0c0ea27e68f7f2b0fe7559edebd27084a0e727e2a2dafc6
|
data/lib/calculator7.rb
CHANGED
@@ -3,7 +3,7 @@ class Calculator7
|
|
3
3
|
puts "Hello world!"
|
4
4
|
end
|
5
5
|
|
6
|
-
def self.
|
6
|
+
def self.compute(str)
|
7
7
|
enable = true
|
8
8
|
str.chars.each do |c|
|
9
9
|
if !"+-*/0123456789 ".include?(c)
|
@@ -15,7 +15,7 @@ class Calculator7
|
|
15
15
|
ret = nil
|
16
16
|
if enable
|
17
17
|
begin
|
18
|
-
ret =
|
18
|
+
ret = eval(str).to_s
|
19
19
|
rescue SyntaxError
|
20
20
|
# do nothing
|
21
21
|
end
|