Module: XlsFunction::FormatString::TransformRules::Texts

Included in:
XlsFunction::FormatString::Transform
Defined in:
lib/xls_function/format_string/transform_rules/texts.rb

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/xls_function/format_string/transform_rules/texts.rb', line 5

def self.included(klass)
  klass.class_eval do
    rule(placeholder: simple(:placeholder)) do
      ->(input) { input.to_s }
    end

    rule(string: simple(:string)) do
      ->(_input) { string.to_s }
    end

    rule(text: subtree(:text)) { text }

    rule(texts: subtree(:texts)) do
      ->(input) { texts.map { |text| text.call(input) }.join }
    end
  end
end