kalculator 0.1.0 → 0.2.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
2
  SHA1:
3
- metadata.gz: a18c933b621aa811fba3ca081470b348175529ea
4
- data.tar.gz: 6ed07d4ffee1aa412db11c5e4d0eaa78316165b3
3
+ metadata.gz: a86a3a471fd726634a4f8417a6ce273c2a06c577
4
+ data.tar.gz: 6c806defc93c0a68a7a4cf175a76dbbdcfdbb41c
5
5
  SHA512:
6
- metadata.gz: f5c54366fb9740454b8fb110436a4e4c6c36927e9858549bd7be94c93feb3db12840d5dd2f9a603625f6a7a331e0f1111ac74a024b90bd1723f5a05e179e7615
7
- data.tar.gz: e065a88e4cc6ebe6f944693fd4a55623fbe4213a96b4e39536d4fa56778e62cb7afa577aba6e1b63c48459b35138a7fb50d82b17c898f4ecb544103c0367eba9
6
+ metadata.gz: 524bc87684c499ac83d0a715b271ae471f39ec53dc8514f05ad2eae9c41c4c2cc4f2909dd8a7ca5293d067141eab0a71537072609443d08b33a0cbfb8a28d77a
7
+ data.tar.gz: 143504c4a02aa61d35ba2103ced6c879a754b12c2304ecee67ff6381b2fb4c4830462868c24de5db014ccd99eece7a3b2774b91f3c79fb305dcca6a42e7fbc87
@@ -60,6 +60,10 @@ class Kalculator
60
60
  number
61
61
  end
62
62
 
63
+ def string(_, string)
64
+ string
65
+ end
66
+
63
67
  def sum(_, array)
64
68
  evaluate(array).inject(0){|sum, num| sum + num}
65
69
  end
@@ -20,6 +20,7 @@ class Kalculator
20
20
  rule(/sum/) { |t| :SUM }
21
21
  rule(/true/) { |t| :TRUE }
22
22
  rule(/false/) { |t| :FALSE }
23
+ rule(/"[^"]*"/) { |t| [:STRING, t[1..-2]] }
23
24
  rule(/[A-Za-z][A-Za-z0-9\._]*/) { |t| [:IDENT, t] }
24
25
  end
25
26
  end
@@ -16,6 +16,7 @@ class Kalculator
16
16
  clause('LPAREN expression RPAREN') { |_, expression, _| expression }
17
17
 
18
18
  clause('NUMBER') { |n| [:number, n] }
19
+ clause('STRING') { |s| [:string, s] }
19
20
  clause('IDENT') { |n| [:variable, n.split(".")] }
20
21
  clause('TRUE') { |n| [:boolean, true] }
21
22
  clause('FALSE') { |n| [:boolean, false] }
@@ -1,3 +1,3 @@
1
1
  class Kalculator
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.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.1.0
4
+ version: 0.2.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-12 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rltk