Class: KDL::Types::Base64
- Inherits:
-
Value::Custom
- Object
- Value
- Value::Custom
- KDL::Types::Base64
- Defined in:
- lib/kdl/types/base64.rb
Constant Summary collapse
- RGX =
/^[A-Za-z0-9+\/=]+$/.freeze
Constants inherited from Value
Instance Attribute Summary
Attributes inherited from Value::Custom
Attributes inherited from Value
Class Method Summary collapse
Methods inherited from Value::Custom
Methods inherited from Value
#==, #as_type, from, #initialize, #inspect, #method_missing, #respond_to_missing?, #stringify_value, #to_s, #to_v2, #version
Constructor Details
This class inherits a constructor from KDL::Value
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class KDL::Value
Class Method Details
.call(value, type = 'base64') ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/kdl/types/base64.rb', line 10 def self.call(value, type = 'base64') return nil unless value.is_a? ::KDL::Value::String unless RGX.match?(value.value) raise ArgumentError, "invalid base64: #{value.value}" end data = ::Base64.decode64(value.value) new(data, type: type) end |