kalculator 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f7ebb299d556d90d2850064b9a43ba651c76e68f0517987600a7f9a05692fc6
4
- data.tar.gz: 7736da10b84c6ef664c2ec29d67848f1247a11272e61400c0bca7e33e8f4ac2e
3
+ metadata.gz: 13f752f4822c544a9380ec994d5c5b82590b6978dd7941b71b094bf703966182
4
+ data.tar.gz: 34b593efc2ac447d573b42c0a55ae286587745d140890a67fcaba6251828352b
5
5
  SHA512:
6
- metadata.gz: 94d5a135534cac641fa0ddc8308fc3b23d3d116eb068923573eef1257e1c4f124fa8c948301637157d696f729277965ffb06c36660ae4a191c4429406954f40f
7
- data.tar.gz: b69f39bf645389c8ece99cc4e701c0da81dc470ed5a10f9045090b41b06656644d33f6127f17efdf55917c9ca70044353072492c445a3c2438d046c4c49bf613
6
+ metadata.gz: d422ae52ab12feaefcd11d62890a2237fb019acd8f4ff7f8654273bcaa6c8b78c574e4b8bb1646130e8e1f7bf9a70241a3055297c1d1956e770cfad83147115f
7
+ data.tar.gz: 5ababeb0c7d56779087bbb76832c11f9809d4eea954a993449e2e6022626690805aa1e26490092a8814c478aefa196bb8b301676829ef2a4c9bfdf45918c38b5
@@ -6,6 +6,7 @@ require "kalculator/formula"
6
6
  require "kalculator/lexer"
7
7
  require "kalculator/nested_lookup"
8
8
  require "kalculator/parser"
9
+ require "kalculator/transform"
9
10
  require "kalculator/version"
10
11
 
11
12
  class Kalculator
@@ -16,4 +17,8 @@ class Kalculator
16
17
  def self.new(*args)
17
18
  Kalculator::Formula.new(*args)
18
19
  end
20
+
21
+ def self.parse(formula)
22
+ Kalculator::Parser.parse(Kalculator::Lexer.lex(formula))
23
+ end
19
24
  end
@@ -0,0 +1,15 @@
1
+ class Kalculator
2
+ module Transform
3
+ def self.run(node, &block)
4
+ new_node = yield node
5
+ return new_node if is_terminal?(new_node)
6
+ args = new_node[1..-1].map{ |arg| run(arg, &block) }
7
+ args.unshift(new_node.first)
8
+ end
9
+
10
+ def self.is_terminal?(node)
11
+ return false if node.is_a?(Array) && node.first.is_a?(Symbol)
12
+ true
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  class Kalculator
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kalculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Ries
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-14 00:00:00.000000000 Z
11
+ date: 2018-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rltk
@@ -96,6 +96,7 @@ files:
96
96
  - lib/kalculator/lexer.rb
97
97
  - lib/kalculator/nested_lookup.rb
98
98
  - lib/kalculator/parser.rb
99
+ - lib/kalculator/transform.rb
99
100
  - lib/kalculator/version.rb
100
101
  homepage: https://github.com/mmmries/kalculator
101
102
  licenses: