kalculator 0.2.1 → 0.3.0

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
- SHA1:
3
- metadata.gz: 50725a89c0d8187d980f2a8f250a333c52e6c0c0
4
- data.tar.gz: f684b6d36c46254dc2dc8336c613c25c8b0e3097
2
+ SHA256:
3
+ metadata.gz: df50bd8eebb0124d8656b68a187b42963c2a8d1a4e14018e79f9b2e12fa9e77e
4
+ data.tar.gz: e414204de2fca16a6ee2313508dc4c10aa9755ddc9fd95ab77083c72b33c1687
5
5
  SHA512:
6
- metadata.gz: c07c402094c36cd412a173c8edfe16ac4b2436627cc20aede88a11a4c8fe091d2bc3bc37cc5da479955fb467a7d039ec1864b947a55ee08dd1d7e621f43169a4
7
- data.tar.gz: 1cdddcef2cc96ee32753d038dfc39ea9a8ba235ee99b2e90026eae727b3bb2395fea0948d74f4f2fa8c98b6458214dc56fe4b3bf6f76b8e9e3649c5a92951668
6
+ metadata.gz: f2bdd16d1393e2f1991aa0240cbe4ea761fd4b3db0bb1ec2711646fd855305dac8eff52d9c6a271a2a6df39c5eaffaf9623ade7ba9984b7ac122c0454cd9e4d4
7
+ data.tar.gz: 74102a128ee39aa879a5380a0c7934b0d5bc11ee618553431808e39dd390c873c4a6246338e587c6c7a4de4051622564444d11cd005dca6927e95845c06763eb
data/lib/kalculator.rb CHANGED
@@ -2,23 +2,17 @@ require "rltk"
2
2
  require "kalculator/data_sources"
3
3
  require "kalculator/errors"
4
4
  require "kalculator/evaluator"
5
+ require "kalculator/formula"
5
6
  require "kalculator/lexer"
6
7
  require "kalculator/parser"
7
8
  require "kalculator/version"
8
9
 
9
10
  class Kalculator
10
11
  def self.evaluate(formula, data_source = {})
11
- new(formula).evaluate(data_source)
12
+ Kalculator::Formula.new(formula).evaluate(data_source)
12
13
  end
13
14
 
14
- attr_reader :ast, :string
15
-
16
- def initialize(string)
17
- @ast = Kalculator::Parser.parse(Kalculator::Lexer.lex(string))
18
- @string = string
19
- end
20
-
21
- def evaluate(data_source = {})
22
- Kalculator::Evaluator.new(data_source).evaluate(ast)
15
+ def self.new(*args)
16
+ Kalculator::Formula.new(*args)
23
17
  end
24
18
  end
@@ -0,0 +1,14 @@
1
+ class Kalculator
2
+ class Formula
3
+ attr_reader :ast, :string
4
+
5
+ def initialize(string)
6
+ @ast = Kalculator::Parser.parse(Kalculator::Lexer.lex(string))
7
+ @string = string
8
+ end
9
+
10
+ def evaluate(data_source = {})
11
+ Kalculator::Evaluator.new(data_source).evaluate(ast)
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  class Kalculator
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
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.2.1
4
+ version: 0.3.0
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-04-13 00:00:00.000000000 Z
11
+ date: 2018-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rltk
@@ -92,6 +92,7 @@ files:
92
92
  - lib/kalculator/data_sources.rb
93
93
  - lib/kalculator/errors.rb
94
94
  - lib/kalculator/evaluator.rb
95
+ - lib/kalculator/formula.rb
95
96
  - lib/kalculator/lexer.rb
96
97
  - lib/kalculator/parser.rb
97
98
  - lib/kalculator/version.rb
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  version: '0'
116
117
  requirements: []
117
118
  rubyforge_project:
118
- rubygems_version: 2.6.14
119
+ rubygems_version: 2.7.6
119
120
  signing_key:
120
121
  specification_version: 4
121
122
  summary: A calculator that can safely and quickly interpret user-input