xls_function 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +1 -1
- data/README.md +2 -0
- data/lib/xls_function/error.rb +6 -0
- data/lib/xls_function/evaluators/binary_operations/divide.rb +9 -0
- data/lib/xls_function/locales/en.yml +1 -0
- data/lib/xls_function/locales/ja.yml +1 -0
- data/lib/xls_function/parse_rules/binary_operation.rb +1 -1
- data/lib/xls_function/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 061aed8566bf5bc16a1ddc0a7ea54237bdc8663971427dae4260373b815aca80
|
4
|
+
data.tar.gz: 8ad8571368b22fb3d6fc0207cb51cde4e94959e33a5d6020d535c3b16018e5eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d08ab1ac4bac791ff2a9af2d47eb3fc8914605ca77244d8c94a627d82dbefeec427dcfe04a6e9137530b8c778f1670e5cacfb588e5aefbab897876df9b4a383e
|
7
|
+
data.tar.gz: 630273a532af81bd5c9ab07ea1c2c1b67d057d3362c3e4e5c25b365aa499c279aeb9b1ceabae159bfde8b73d414d4fe55082ad2e7ecf1d3b38d5f5084257e8dc
|
data/.github/workflows/rspec.yml
CHANGED
data/README.md
CHANGED
@@ -38,6 +38,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
38
38
|
|
39
39
|
Bug reports and pull requests are welcome on GitHub at https://github.com/moneyforward/xls_function. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](./CODE_OF_CONDUCT.md).
|
40
40
|
|
41
|
+
- You can create a pull request to the main branch.
|
42
|
+
- You should not change the version on your pull request.
|
41
43
|
|
42
44
|
## License
|
43
45
|
|
data/lib/xls_function/error.rb
CHANGED
@@ -34,12 +34,18 @@ module XlsFunction
|
|
34
34
|
def na(error_info = '')
|
35
35
|
new(ERROR_NA, error_info)
|
36
36
|
end
|
37
|
+
|
38
|
+
# @return #DIV/0!
|
39
|
+
def div0!(error_info = '')
|
40
|
+
new(ERROR_DIV0, error_info)
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
39
44
|
|
40
45
|
ERROR_VALUE = '#VALUE!'.freeze
|
41
46
|
ERROR_NUM = '#NUM!'.freeze
|
42
47
|
ERROR_NA = '#N/A'.freeze
|
48
|
+
ERROR_DIV0 = '#DIV/0!'.freeze
|
43
49
|
|
44
50
|
ERRORS = [
|
45
51
|
ERROR_VALUE,
|
@@ -5,8 +5,17 @@ module XlsFunction
|
|
5
5
|
operator_as '/'
|
6
6
|
|
7
7
|
def eval
|
8
|
+
return ::XlsFunction::ErrorValue.div0!(divide_by_zero) if right.zero?
|
9
|
+
|
8
10
|
left / right
|
9
11
|
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def divide_by_zero
|
16
|
+
message = error_message(:cannot_divide_by_zero)
|
17
|
+
class_info(message)
|
18
|
+
end
|
10
19
|
end
|
11
20
|
end
|
12
21
|
end
|
@@ -64,4 +64,5 @@ en:
|
|
64
64
|
cannot_convert_to_number: Cannot convert %{source} to number.
|
65
65
|
cannot_convert_to_date: Cannot convert %{source} to date.
|
66
66
|
cannot_convert_to_time: Cannot convert %{source} to time.
|
67
|
+
cannot_divide_by_zero: "Cannot divide by zero."
|
67
68
|
invalid_value_for_function: Invalid value for formula or function.
|
@@ -7,7 +7,7 @@ module XlsFunction
|
|
7
7
|
rule(:multiple_divide_operator) { match['*/'].as(:operator) >> space? }
|
8
8
|
rule(:plus_minus_opeartor) { match['+-'].as(:operator) >> space? }
|
9
9
|
rule(:concat_opeartor) { str('&').as(:operator) >> space? }
|
10
|
-
rule(:comparison_operator) { (str('
|
10
|
+
rule(:comparison_operator) { (str('<>') | str('>=') | str('<=') | str('>') | str('<') | str('=')).as(:operator) >> space? }
|
11
11
|
|
12
12
|
rule(:binary_operation) do
|
13
13
|
infix_expression(
|
data/lib/xls_function/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xls_function
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nakakuki Shingo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|