rrpn 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/rrpn.rb +5 -5
  4. data/rrpn.gemspec +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dd193f6ca23427ec0dbdd608d5ca69f92275361
4
- data.tar.gz: ef26048dd880fe03516eafe274b5cff16880bfdf
3
+ metadata.gz: dce10c5255e618e1569cee575178957017ecf427
4
+ data.tar.gz: 9ff65fd6fb376ad3f63ad042de8a299a88c997ab
5
5
  SHA512:
6
- metadata.gz: f8a4f40475a9ab08c55eb29d6440405beeb80ce4cb45dc45d7d5c491f7d5e815476c37ae34f9a9cc5d1d2c1b6e1d553967361fcc419410fa8e4053edf7f3b237
7
- data.tar.gz: 70fc6d5c5ec1c44cc11a8d8817bed7262cb419b2fdd3eec764fa196d04d5c035024e498efda3a30d27f4175e742af80fe7cd76e26b55bfdd07bace727816443d
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, (0+2i), :+, 3, (0+3i), :+, :+]
56
+ p rpn.queue #=> [1, "2i", :+, 3, "3i", :+, :+]
57
57
  p rpn.calc #=> (4+5i)
58
- puts rpn #=> 1 0+2i + 3 0+3i + +
58
+ puts rpn #=> 1 2i + 3 3i + +
59
59
  ```
60
60
 
61
61
  Other
@@ -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].to_s
52
+ return tree[1]
53
53
  when :@imaginary
54
- return tree[1].to_c
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.flatten
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
- @queue.join(' ')
71
+ queue.join(' ')
72
72
  end
73
73
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "rrpn"
7
- spec.version = "1.0.0"
7
+ spec.version = "1.1.0"
8
8
  spec.authors = ["siman-man"]
9
9
  spec.email = ["k128585@ie.u-ryukyu.ac.jp"]
10
10
 
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.0.0
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-02-21 00:00:00.000000000 Z
11
+ date: 2017-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler