Module: Cel::Extensions::Encoders::Base64
- Defined in:
- lib/cel/extensions/encoders.rb
Class Method Summary collapse
- .__check(funcall, checker:) ⇒ Object
- .decode(str, program:) ⇒ Object
- .encode(str, program:) ⇒ Object
- .implicit? ⇒ Boolean
Class Method Details
.__check(funcall, checker:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cel/extensions/encoders.rb', line 13 def __check(funcall, checker:) func = funcall.func args = funcall.args case func when :encode checker.check_arity(func, args, 1) arg = checker.call(args.first) return TYPES[:string] if checker.find_match_all_types(%i[bytes], arg) when :decode checker.check_arity(func, args, 1) arg = checker.call(args.first) return TYPES[:bytes] if checker.find_match_all_types(%i[string], arg) end checker.unsupported_operation(funcall) end |
.decode(str, program:) ⇒ Object
37 38 39 40 41 |
# File 'lib/cel/extensions/encoders.rb', line 37 def decode(str, program:) value = program.call(str).value Cel::Bytes.new(value.unpack1("m").unpack("C*")) end |
.encode(str, program:) ⇒ Object
31 32 33 34 35 |
# File 'lib/cel/extensions/encoders.rb', line 31 def encode(str, program:) value = program.call(str).value Cel::String.new([value.pack("C*")].pack("m0")) end |
.implicit? ⇒ Boolean
9 10 11 |
# File 'lib/cel/extensions/encoders.rb', line 9 def implicit? false end |