xls_function 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish_gem.yml +1 -1
- data/.github/workflows/rspec.yml +1 -1
- data/lib/xls_function/evaluators/functions/asc.rb +1 -1
- data/lib/xls_function/evaluators/functions/switch.rb +28 -0
- data/lib/xls_function/locales/en.yml +2 -0
- data/lib/xls_function/locales/ja.yml +2 -0
- data/lib/xls_function/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d89dc2c4c24ab355dcd3032d8af3cb247b2d47a94109313971dd23095e7cdece
|
4
|
+
data.tar.gz: b8a6de61ef6de6231e635ef83df5994ef7996a7b6d615b11d6f5f9aafdf23002
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84972bfd1090adf2a001a72903d6a2a950ba89a7b6d4211cf19c2e73803b98efc645b6faddb3374629213ad72508ce3aa7d5258dae54452a80fa8e922723a2c5
|
7
|
+
data.tar.gz: afd2248e25cfc03052ff8108daf758d3cca969391ea22854dc1f501b75b0752696263a908be222f95ba06d2e494b6b5a7f369f1bdb48c13cf71cc0efb62d5422
|
@@ -11,7 +11,7 @@ jobs:
|
|
11
11
|
build:
|
12
12
|
runs-on: ubuntu-latest
|
13
13
|
steps:
|
14
|
-
- uses: actions/checkout@
|
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")
|
data/.github/workflows/rspec.yml
CHANGED
@@ -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@
|
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: 一致する値がない場合に返す値が指定されていません。
|
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.7
|
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: 2024-06-06 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
|