Class: IABConsentString::Consent::VendorConsentDecoder
- Inherits:
-
Object
- Object
- IABConsentString::Consent::VendorConsentDecoder
- Defined in:
- lib/iab_consent_string/consent/vendor_consent_decoder.rb
Overview
IABConsentString::Consent::VendorConsent decoder from Base64 string. Right now only version 1 is know, but eventually this can be extended to support new versions
Class Method Summary collapse
-
.fromBase64String(consentString) ⇒ IABConsentString::Consent::VendorConsent
Build a IABConsentString::Consent::VendorConsent object from a base64 string.
- .fromByteArray(bytes) ⇒ Object
- .getVersion(bits) ⇒ Object
Class Method Details
.fromBase64String(consentString) ⇒ IABConsentString::Consent::VendorConsent
Build a IABConsentString::Consent::VendorConsent object from a base64 string
15 16 17 18 19 20 |
# File 'lib/iab_consent_string/consent/vendor_consent_decoder.rb', line 15 def self.fromBase64String() if .nil? raise "Null or empty consent string passed as an argument" end fromByteArray(Base64.urlsafe_decode64().bytes.to_a) end |
.fromByteArray(bytes) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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) ⇒ Object
36 37 38 |
# 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 |