xls_function 0.1.2 → 0.1.4

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: 2cb7d73e2dd1bb1c3c52f2281041b90a138757cb2c95de1fe19a8c8081a2c25e
4
- data.tar.gz: 0eea9207be1c050b0885e9368f69a0db3ece73631dd117b6eb039e52764d39f5
3
+ metadata.gz: 19795c0020e6176ec325435eb1e451edf5dae9e8c9a4c155e86d8fe56e49c061
4
+ data.tar.gz: a4d9775f07d72cd19d6b9cc3e666b298e38ee9becb0e0bb5289b828486e882fb
5
5
  SHA512:
6
- metadata.gz: 1d5b1a4ceaff20676d93c6f6aa8ec5396f570b2809e9edbca5325d11e471b8337c6a102d3db9f5a446f7ddf15961a980445ad5315047549816739649b330020d
7
- data.tar.gz: 28d06f5116060f72ca79b751800cbe8ee102eab6e8757c7d7f112049798f4a2b4ab2cbe1637031192a4e542953d523de7af51f6b852fca185403ac10ff05802e
6
+ metadata.gz: a15c9d2bb4f02479f3b8794f229a8a1d9399bead0db1ab77970f32e94217ed6fe0de7e6d405dc04091f33199756e279f6e599107526c8bee7a6723536193134e
7
+ data.tar.gz: 5992e88d6f7bd1b4f7aa56cd7d8dffccf3bec79c79ea7393be2a92e07561f608ef0ab48c39864bec605541d81b8d2844501d5e20c80a9bd4617964b69e299731
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
@@ -13,6 +13,8 @@ module XlsFunction
13
13
  arg_list.each_slice(2) do |expr, value|
14
14
  return value&.evaluate(context) if expr&.evaluate(context)
15
15
  end
16
+
17
+ nil
16
18
  end
17
19
  end
18
20
  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: 値が数式または関数に対して無効です。
@@ -1,3 +1,3 @@
1
1
  module XlsFunction
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.4'.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.2
4
+ version: 0.1.4
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-22 00:00:00.000000000 Z
11
+ date: 2023-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n