kalculator 0.6.1 → 0.6.2

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: c192de434bfd521b2abde4bcdd7e19b33aabf7315eec6b999687478aa8a2321b
4
- data.tar.gz: a66810da20caf1fe4a2b682d987b081c58c71aeeb74dec0ac99e69aab1d0168d
3
+ metadata.gz: bd0089994743a43b5b8ad0b502bfc53758e08ed86f43f521f7e3df5c2d3d6508
4
+ data.tar.gz: 2946da73cce1290a9be9fd632af0bfc47b617838e847450196cf869e6d7b6e0e
5
5
  SHA512:
6
- metadata.gz: d5c9b29cf0b2f2bb327610407e499ece24abc585b4f3f543de7cf31593fe2ad8836fe0038f5c37750c59e2959e27418e5b710d211bc2d89d065074dcc2f10bed
7
- data.tar.gz: c7aa10d0ea25bc227ea19e4c160bca130e1fdcd417de0318e722c8813eb8df630adad85fad3413537fd1f9e8243ad17591a5e625762148ba0ed49a9026269bbd
6
+ metadata.gz: 28286114fd1e503f677099ffb567c1ab4eb899f7a4c2ec1d115fe073424a90d527d1f6416e673538a63afb6ed4e81b78e0ec8ae89763441a4f2f2f6fb1b26e8b
7
+ data.tar.gz: 12aeacb74451dad37bd06567b92cf4cd585dac83be897325f756a7d74365d297d736a3c06c54643242282ffe55bab455cdcbf6888138effbaaf0403e6ff2a550
@@ -128,6 +128,10 @@ class Kalculator
128
128
  number
129
129
  end
130
130
 
131
+ def percent(_, percent)
132
+ percent / 100.0
133
+ end
134
+
131
135
  def string(_, string)
132
136
  string
133
137
  end
@@ -19,6 +19,9 @@ class Kalculator
19
19
  rule(/AND/) { :AND }
20
20
  rule(/OR/) { :OR }
21
21
  rule(/!/) { :BANG }
22
+ rule(/\-?\d+%/) { |t| [:PERCENT, t.to_i] }
23
+ rule(/\-?\.\d+%/) { |t| [:PERCENT, t.to_f] }
24
+ rule(/\-?\d+\.\d+%/) { |t| [:PERCENT, t.to_f] }
22
25
  rule(/\-?\d+/) { |t| [:NUMBER, t.to_i] }
23
26
  rule(/\-?\.\d+/) { |t| [:NUMBER, t.to_f] }
24
27
  rule(/\-?\d+\.\d+/) { |t| [:NUMBER, t.to_f] }
@@ -31,6 +31,7 @@ class Kalculator
31
31
  clause('LBRACKET expressions RBRACKET') { |_, expressions, _| [:list, expressions] }
32
32
 
33
33
  clause('NUMBER') { |n| [:number, n] }
34
+ clause('PERCENT') { |n| [:percent, n] }
34
35
  clause('STRING') { |s| [:string, s] }
35
36
  clause('IDENT') { |n| [:variable, n] }
36
37
  clause('TRUE') { |n| [:boolean, true] }
@@ -1,3 +1,3 @@
1
1
  class Kalculator
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
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.6.1
4
+ version: 0.6.2
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-10-18 00:00:00.000000000 Z
11
+ date: 2018-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rltk