xls_function 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 061aed8566bf5bc16a1ddc0a7ea54237bdc8663971427dae4260373b815aca80
4
- data.tar.gz: 8ad8571368b22fb3d6fc0207cb51cde4e94959e33a5d6020d535c3b16018e5eb
3
+ metadata.gz: 54ae1faab061c50b74be84af940d8dbe34b66ae5eb491f143e83d565ef3f09b1
4
+ data.tar.gz: ca06d18d55b9aa74592f9d3c45aac3960aec168becbb0e4fbe832cf287297155
5
5
  SHA512:
6
- metadata.gz: d08ab1ac4bac791ff2a9af2d47eb3fc8914605ca77244d8c94a627d82dbefeec427dcfe04a6e9137530b8c778f1670e5cacfb588e5aefbab897876df9b4a383e
7
- data.tar.gz: 630273a532af81bd5c9ab07ea1c2c1b67d057d3362c3e4e5c25b365aa499c279aeb9b1ceabae159bfde8b73d414d4fe55082ad2e7ecf1d3b38d5f5084257e8dc
6
+ metadata.gz: f9cb69cbe595884d61b029dd2ce154682faad715bed9ccc1df98a41605e9b8549fad2b8ee1860a4866dbe283a4f91e62572fc664105db94402303e5e8ded08ee
7
+ data.tar.gz: 74c70b4e345e9cf7120b0080eecf1e0d25f2ab82336107beb3da75f23aa933511034f47517cbe8b2baf372da626acc1d28478e77eccaf780aff44eb627aeacad
@@ -11,7 +11,7 @@ jobs:
11
11
  build:
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v3
15
15
  - name: Tag with the gem version
16
16
  run: |
17
17
  GEM_VERSION=$(ruby -e "require 'rubygems'; gemspec = Dir.glob(\"./**/*.gemspec\").first; puts Gem::Specification::load(gemspec).version")
@@ -18,7 +18,7 @@ jobs:
18
18
  ruby-version: ['2.7', '3.0', '3.1', '3.2']
19
19
 
20
20
  steps:
21
- - uses: actions/checkout@v2
21
+ - uses: actions/checkout@v3
22
22
  - name: Set up Ruby
23
23
  # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
24
24
  # change this to (see https://github.com/ruby/setup-ruby#versioning)
@@ -0,0 +1,28 @@
1
+ module XlsFunction
2
+ module Evaluators
3
+ module Functions
4
+ class Switch < ::XlsFunction::Evaluators::FunctionEvaluator
5
+ function_as :switch
6
+
7
+ def eval_arglist
8
+ # Skip common argument evaluation and assignment for short-circuit
9
+ end
10
+
11
+ def eval
12
+ condition = arg_list.first.evaluate(context)
13
+
14
+ arg_list[1..-1].each_slice(2) do |expr, value|
15
+ ex_value = expr&.evaluate(context)
16
+ in_value = value&.evaluate(context)
17
+
18
+ return in_value if ex_value == condition
19
+
20
+ return ex_value if in_value.nil?
21
+ end
22
+
23
+ XlsFunction::ErrorValue.na(class_info(error_message(:missing_value_for_function)))
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -57,6 +57,7 @@ en:
57
57
  upper: UPPER(text) Converts text to uppercase.
58
58
  value: VALUE(text) Converts a text string that represents a number to a number.
59
59
  year: YEAR(serial_number) Returns the year corresponding to a date. The year is returned as an integer in the range 1900-9999.
60
+ switch: SWITCH(Value to switch, Value to match1...[2-126], Value to return if there's a match1...[2-126], Value to return if there's no match) Where you can evaluate up to 126 matching values and results.
60
61
  errors:
61
62
  out_of_range: Value is out of range. %{value}
62
63
  missing_target: Missing %{target} in %{source}.
@@ -66,3 +67,4 @@ en:
66
67
  cannot_convert_to_time: Cannot convert %{source} to time.
67
68
  cannot_divide_by_zero: "Cannot divide by zero."
68
69
  invalid_value_for_function: Invalid value for formula or function.
70
+ missing_value_for_function: "'Value to return if no matching value' is not specified."
@@ -57,6 +57,7 @@ ja:
57
57
  upper: UPPER(文字列) 文字列を大文字に変換します。
58
58
  value: VALUE(文字列) 数値を表す文字列を数値に変換します。
59
59
  year: YEAR(シリアル値) 日付に対応する年を返します。 戻り値は、1900 (年) ~ 9999 (年) の範囲の整数となります。
60
+ switch: SWITCH(交換する値, 一致する値1...[2-126], 一致する値1...[2-126] がある場合に返す値, 一致する値がない場合に返す値) 最大 126 個の一致する値と結果を評価することができます
60
61
  errors:
61
62
  out_of_range: 範囲外の値が指定されています。%{value}
62
63
  missing_target: 文字列%{source}中に%{target}が見つかりません。
@@ -66,3 +67,4 @@ ja:
66
67
  cannot_convert_to_time: "%{source}は時刻に変換できません。"
67
68
  cannot_divide_by_zero: "0除算が発生しました。"
68
69
  invalid_value_for_function: 値が数式または関数に対して無効です。
70
+ missing_value_for_function: 一致する値がない場合に返す値が指定されていません。
@@ -1,3 +1,3 @@
1
1
  module XlsFunction
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.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.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nakakuki Shingo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-24 00:00:00.000000000 Z
11
+ date: 2024-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -145,6 +145,7 @@ files:
145
145
  - lib/xls_function/evaluators/functions/sign.rb
146
146
  - lib/xls_function/evaluators/functions/sqrt.rb
147
147
  - lib/xls_function/evaluators/functions/substitute.rb
148
+ - lib/xls_function/evaluators/functions/switch.rb
148
149
  - lib/xls_function/evaluators/functions/text.rb
149
150
  - lib/xls_function/evaluators/functions/time.rb
150
151
  - lib/xls_function/evaluators/functions/timevalue.rb