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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78fe15af8eb4b5dafce02e10b89a8328b1e025d035e1349982faceebfe40aa43
4
- data.tar.gz: 52223d13a8aae89a0998e08b349299d63968c178192c549d7b03ff7a8347cf91
3
+ metadata.gz: 061aed8566bf5bc16a1ddc0a7ea54237bdc8663971427dae4260373b815aca80
4
+ data.tar.gz: 8ad8571368b22fb3d6fc0207cb51cde4e94959e33a5d6020d535c3b16018e5eb
5
5
  SHA512:
6
- metadata.gz: 1b05087ff9d7379fd8b4608f304162f8a1d69b623e5ced9b9e93f62b521c4b8fc5cfe91f526554e2c57416da7c626b5b76ecb90652a20b0d6af712fae4339f1a
7
- data.tar.gz: 2a304ec0fcd97fc916833ea8be32f37fcd873e937638c68cc27527222c114842bb0a71b09bf2bbd3747b4c6c8a1cd92062ffec94089ce687007ac6a8dc72daf3
6
+ metadata.gz: d08ab1ac4bac791ff2a9af2d47eb3fc8914605ca77244d8c94a627d82dbefeec427dcfe04a6e9137530b8c778f1670e5cacfb588e5aefbab897876df9b4a383e
7
+ data.tar.gz: 630273a532af81bd5c9ab07ea1c2c1b67d057d3362c3e4e5c25b365aa499c279aeb9b1ceabae159bfde8b73d414d4fe55082ad2e7ecf1d3b38d5f5084257e8dc
@@ -15,7 +15,7 @@ jobs:
15
15
  runs-on: ubuntu-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby-version: ['2.7', '3.0', '3.1']
18
+ ruby-version: ['2.7', '3.0', '3.1', '3.2']
19
19
 
20
20
  steps:
21
21
  - uses: actions/checkout@v2
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
 
@@ -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.
@@ -64,4 +64,5 @@ ja:
64
64
  cannot_convert_to_number: "%{source}は数値に変換できません。"
65
65
  cannot_convert_to_date: "%{source}は日付に変換できません。"
66
66
  cannot_convert_to_time: "%{source}は時刻に変換できません。"
67
+ cannot_divide_by_zero: "0除算が発生しました。"
67
68
  invalid_value_for_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('>') | str('>=') | str('<') | str('<=') | str('=') | str('<>')).as(:operator) >> space? }
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(
@@ -1,3 +1,3 @@
1
1
  module XlsFunction
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
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.3
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: 2022-12-23 00:00:00.000000000 Z
11
+ date: 2023-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n