hesabu 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/lib/hesabu/types/fun_call.rb +19 -1
- data/lib/hesabu/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abe943d484f4a7c14677bbd0edaa584a9705718b76dbf6584e827c61d804b290
|
4
|
+
data.tar.gz: feb5c1e48b9bd534e9e780b282e4dc0c246b77c6c9897b7d355acb23efa19967
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d85f9343ef7f93028552e8ccf73be54c5eac7d4210a9172666f06b72bf941660e9bf21f528c5bc3a53236566963bb3b832b17456349f3959f5047e4d9831e5c1
|
7
|
+
data.tar.gz: 696f4a816991e4fcf72cf1291c3c392215d2d7f13f1ebc167db32ae80cfdfa8d27ad38a802eae91d58e416f063a7bd744e6f4dfa56fc5a83333b92cd1956fd0e
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Gem](https://img.shields.io/gem/v/hesabu.svg)](https://rubygems.org/gems/hesabu)
|
1
2
|
[![Maintainability](https://api.codeclimate.com/v1/badges/f2643a76ea031525ed1f/maintainability)](https://codeclimate.com/github/BLSQ/hesabu/maintainability)
|
2
3
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/f2643a76ea031525ed1f/test_coverage)](https://codeclimate.com/github/BLSQ/hesabu/test_coverage)
|
3
4
|
[![Build Status](https://travis-ci.org/BLSQ/hesabu.svg?branch=master)](https://travis-ci.org/BLSQ/hesabu)
|
@@ -7,6 +8,26 @@
|
|
7
8
|
Hesabu : equation solver based on parslet.
|
8
9
|
|
9
10
|
|
11
|
+
## deployment to rubygems.org
|
12
|
+
|
13
|
+
one time setup
|
14
|
+
|
15
|
+
```
|
16
|
+
gem install gem-release
|
17
|
+
curl -u rubygemaccount https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
|
18
|
+
chmod 0600 ~/.gem/credentials
|
19
|
+
|
20
|
+
```
|
21
|
+
|
22
|
+
|
23
|
+
```
|
24
|
+
gem bump
|
25
|
+
gem build hesabu.gemspec
|
26
|
+
gem push hesabu-x.x.x.gem
|
27
|
+
|
28
|
+
```
|
29
|
+
|
30
|
+
|
10
31
|
## License
|
11
32
|
|
12
33
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -67,6 +67,22 @@ module Hesabu
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
class AbsFunction
|
71
|
+
def call(args)
|
72
|
+
raise "expected args #{self.class.name} : #{args}" if args.size != 1
|
73
|
+
args.first.eval.abs
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class AccessFunction
|
78
|
+
def call(args)
|
79
|
+
values = args.map(&:eval)
|
80
|
+
array = values[0..-2]
|
81
|
+
index = values[-1]
|
82
|
+
array[index]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
70
86
|
FUNCTIONS = {
|
71
87
|
"if" => IfFunction.new,
|
72
88
|
"sum" => SumFunction.new,
|
@@ -75,7 +91,9 @@ module Hesabu
|
|
75
91
|
"max" => MaxFunction.new,
|
76
92
|
"safe_div" => SafeDivFunction.new,
|
77
93
|
"randbetween" => RandbetweenFunction.new,
|
78
|
-
"score_table" => ScoreTableFunction.new
|
94
|
+
"score_table" => ScoreTableFunction.new,
|
95
|
+
"abs" => AbsFunction.new,
|
96
|
+
"access" => AccessFunction.new,
|
79
97
|
}.freeze
|
80
98
|
|
81
99
|
FunCall = Struct.new(:name, :args) do
|
data/lib/hesabu/version.rb
CHANGED