Class: IABConsentString::Consent::Implementation::V1::ByteBufferBackedVendorConsent
- Inherits:
-
VendorConsent
- Object
- VendorConsent
- IABConsentString::Consent::Implementation::V1::ByteBufferBackedVendorConsent
- Defined in:
- lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb
Instance Method Summary collapse
- #getAllowedPurposeIds ⇒ Object
- #getAllowedPurposes ⇒ Object
- #getAllowedPurposesBits ⇒ Object
- #getCmpId ⇒ Object
- #getCmpVersion ⇒ Object
- #getConsentLanguage ⇒ Object
- #getConsentRecordCreated ⇒ Object
- #getConsentRecordLastUpdated ⇒ Object
- #getConsentScreen ⇒ Object
- #getMaxVendorId ⇒ Object
- #getVendorListVersion ⇒ Object
- #getVersion ⇒ Object
- #hashCode ⇒ Object
-
#initialize(bits) ⇒ ByteBufferBackedVendorConsent
constructor
A new instance of ByteBufferBackedVendorConsent.
- #isPurposeAllowed(purpose) ⇒ Object
- #isPurposeIdAllowed(purposeId) ⇒ Object
- #isVendorAllowed(vendorId) ⇒ Object
- #toByteArray ⇒ Object
- #toString ⇒ Object
Methods inherited from VendorConsent
Constructor Details
#initialize(bits) ⇒ ByteBufferBackedVendorConsent
Returns a new instance of ByteBufferBackedVendorConsent.
12 13 14 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 12 def initialize(bits) @bits = bits end |
Instance Method Details
#getAllowedPurposeIds ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 48 def getAllowedPurposeIds allowedPurposes = Set[] for i in (IABConsentString::GDPRConstants::PURPOSES_OFFSET...(IABConsentString::GDPRConstants::PURPOSES_OFFSET + IABConsentString::GDPRConstants::PURPOSES_SIZE)) do if (@bits.getBit(i)) allowedPurposes.add(i - IABConsentString::GDPRConstants::PURPOSES_OFFSET + 1) end end allowedPurposes end |
#getAllowedPurposes ⇒ Object
58 59 60 61 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 58 def getAllowedPurposes allowedPurposes = getAllowedPurposeIds().map! {|id| IABConsentString::Purpose.new(id)} allowedPurposes.to_a.uniq{|o| [o.getId]}.to_set end |
#getAllowedPurposesBits ⇒ Object
63 64 65 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 63 def getAllowedPurposesBits @bits.getInt(IABConsentString::GDPRConstants::PURPOSES_OFFSET,IABConsentString::GDPRConstants::PURPOSES_SIZE) end |
#getCmpId ⇒ Object
28 29 30 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 28 def getCmpId @bits.getInt(IABConsentString::GDPRConstants::CMP_ID_OFFSET,IABConsentString::GDPRConstants::CMP_ID_SIZE) end |
#getCmpVersion ⇒ Object
32 33 34 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 32 def getCmpVersion @bits.getInt(IABConsentString::GDPRConstants::CMP_VERSION_OFFSET,IABConsentString::GDPRConstants::CMP_VERSION_SIZE) end |
#getConsentLanguage ⇒ Object
40 41 42 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 40 def getConsentLanguage @bits.getSixBitString(IABConsentString::GDPRConstants::CONSENT_LANGUAGE_OFFSET,IABConsentString::GDPRConstants::CONSENT_LANGUAGE_SIZE) end |
#getConsentRecordCreated ⇒ Object
20 21 22 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 20 def getConsentRecordCreated @bits.getDateTimeFromEpochDeciseconds(IABConsentString::GDPRConstants::CREATED_BIT_OFFSET, IABConsentString::GDPRConstants::CREATED_BIT_SIZE) end |
#getConsentRecordLastUpdated ⇒ Object
24 25 26 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 24 def getConsentRecordLastUpdated @bits.getDateTimeFromEpochDeciseconds(IABConsentString::GDPRConstants::UPDATED_BIT_OFFSET,IABConsentString::GDPRConstants::UPDATED_BIT_SIZE) end |
#getConsentScreen ⇒ Object
36 37 38 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 36 def getConsentScreen @bits.getInt(IABConsentString::GDPRConstants::CONSENT_SCREEN_SIZE_OFFSET,IABConsentString::GDPRConstants::CONSENT_SCREEN_SIZE) end |
#getMaxVendorId ⇒ Object
67 68 69 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 67 def getMaxVendorId @bits.getInt(IABConsentString::GDPRConstants::MAX_VENDOR_ID_OFFSET,IABConsentString::GDPRConstants::MAX_VENDOR_ID_SIZE) end |
#getVendorListVersion ⇒ Object
44 45 46 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 44 def getVendorListVersion @bits.getInt(IABConsentString::GDPRConstants::VENDOR_LIST_VERSION_OFFSET,IABConsentString::GDPRConstants::VENDOR_LIST_VERSION_SIZE) end |
#getVersion ⇒ Object
16 17 18 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 16 def getVersion @bits.getInt(IABConsentString::GDPRConstants::VERSION_BIT_OFFSET,IABConsentString::GDPRConstants::VERSION_BIT_SIZE) end |
#hashCode ⇒ Object
99 100 101 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 99 def hashCode @bit.toByteArray().toString().hash end |
#isPurposeAllowed(purpose) ⇒ Object
78 79 80 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 78 def isPurposeAllowed(purpose) isPurposeIdAllowed(purpose.getId()) end |
#isPurposeIdAllowed(purposeId) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 71 def isPurposeIdAllowed(purposeId) if ((purposeId < 1) || (purposeId > IABConsentString::GDPRConstants::PURPOSES_SIZE)) return false end @bits.getBit(IABConsentString::GDPRConstants::PURPOSES_OFFSET + purposeId - 1); end |
#isVendorAllowed(vendorId) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 82 def isVendorAllowed(vendorId) if ((vendorId < 1) || (vendorId > getMaxVendorId())) return false end if (encodingType() == IABConsentString::GDPRConstants::VENDOR_ENCODING_RANGE) defaultConsent = @bits.getBit(IABConsentString::GDPRConstants::DEFAULT_CONSENT_OFFSET) present = isVendorPresentInRange(vendorId) return (present != defaultConsent) else return @bits.getBit(IABConsentString::GDPRConstants::VENDOR_BITFIELD_OFFSET + vendorId - 1) end end |
#toByteArray ⇒ Object
95 96 97 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 95 def toByteArray @bits.toByteArray() end |
#toString ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 103 def toString "ByteBufferVendorConsent{" + "Version=" + getVersion().to_s + ",Created=" + getConsentRecordCreated().to_s + ",LastUpdated=" + getConsentRecordLastUpdated().to_s + ",CmpId=" + getCmpId().to_s + ",CmpVersion=" + getCmpVersion().to_s + ",ConsentScreen=" + getConsentScreen().to_s + ",ConsentLanguage=" + getConsentLanguage() + ",VendorListVersion=" + getVendorListVersion().to_s + ",PurposesAllowed=" + getAllowedPurposeIds().to_s + ",MaxVendorId=" + getMaxVendorId().to_s + ",EncodingType=" + encodingType().to_s + "}" end |