rrpn 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/rrpn.rb +5 -5
- data/rrpn.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dce10c5255e618e1569cee575178957017ecf427
|
4
|
+
data.tar.gz: 9ff65fd6fb376ad3f63ad042de8a299a88c997ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06a0ec43dd9f0aae28d33e6376880e89808277b84a154e8e1164b485b4d446d397f715ad11c8435281dc8840bb06af4a876acabe4a2f910737aa963719bf0ffa
|
7
|
+
data.tar.gz: f27e055055fe4568703b033eb943e9ecd755990039c49f413998741cf31c9be18d9f7f86aa341328bb6cf8d0663c76bc21cb39f59fa0becffdb7af8514451f53
|
data/README.md
CHANGED
@@ -53,9 +53,9 @@ Complex
|
|
53
53
|
|
54
54
|
```ruby
|
55
55
|
rpn = '(1+2i) + (3+3i)'.to_rpn
|
56
|
-
p rpn.queue #=> [1,
|
56
|
+
p rpn.queue #=> [1, "2i", :+, 3, "3i", :+, :+]
|
57
57
|
p rpn.calc #=> (4+5i)
|
58
|
-
puts rpn #=> 1
|
58
|
+
puts rpn #=> 1 2i + 3 3i + +
|
59
59
|
```
|
60
60
|
|
61
61
|
Other
|
data/lib/rrpn.rb
CHANGED
@@ -31,7 +31,7 @@ class RRPN
|
|
31
31
|
def initialize(formula)
|
32
32
|
@formula = formula
|
33
33
|
stree = Ripper.sexp(@formula)
|
34
|
-
@queue = parse(stree[1..-1])
|
34
|
+
@queue = parse(stree[1..-1]).flatten
|
35
35
|
end
|
36
36
|
|
37
37
|
def parse(tree)
|
@@ -49,9 +49,9 @@ class RRPN
|
|
49
49
|
when :@float
|
50
50
|
return tree[1].to_f
|
51
51
|
when :@rational
|
52
|
-
return tree[1]
|
52
|
+
return tree[1]
|
53
53
|
when :@imaginary
|
54
|
-
return tree[1]
|
54
|
+
return tree[1]
|
55
55
|
else
|
56
56
|
if tree[0].instance_of?(Array)
|
57
57
|
queue << parse(tree[0])
|
@@ -60,7 +60,7 @@ class RRPN
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
queue
|
63
|
+
queue
|
64
64
|
end
|
65
65
|
|
66
66
|
def calc
|
@@ -68,6 +68,6 @@ class RRPN
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def to_s
|
71
|
-
|
71
|
+
queue.join(' ')
|
72
72
|
end
|
73
73
|
end
|
data/rrpn.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rrpn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- siman-man
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|