class IABConsentString::Consent::VendorConsentDecoder
IABConsentString::Consent::VendorConsent
decoder from Base64 string. Right now only version 1 is know, but eventually this can be extended to support new versions
Public Class Methods
fromBase64String(consentString)
click to toggle source
Build a IABConsentString::Consent::VendorConsent
object from a base64 string @params consentString [String] a url safe base64 encoded consent string @return [IABConsentString::Consent::VendorConsent] a VendorConsent
object @raise an error when there's a problem with the consentString passed
# File lib/iab_consent_string/consent/vendor_consent_decoder.rb, line 15 def self.fromBase64String(consentString) if consentString.nil? raise "Null or empty consent string passed as an argument" end fromByteArray(Base64.urlsafe_decode64(consentString).bytes.to_a) end
fromByteArray(bytes)
click to toggle source
# File lib/iab_consent_string/consent/vendor_consent_decoder.rb, line 22 def self.fromByteArray(bytes) if ( bytes.nil? || bytes.length == 0) raise "Null or empty consent string passed as an argument" end bits = Bits.new(bytes) version = getVersion(bits) case version when 1 IABConsentString::Consent::Implementation::V1::ByteBufferBackedVendorConsent.new(bits) else raise "Unsupported version: " + version.to_s end end
getVersion(bits)
click to toggle source
# File lib/iab_consent_string/consent/vendor_consent_decoder.rb, line 36 def self.getVersion(bits) bits.getInt(IABConsentString::GDPRConstants::VERSION_BIT_OFFSET, IABConsentString::GDPRConstants::VERSION_BIT_SIZE) end