Class: IABConsentString::Consent::Implementation::V1::ByteBufferBackedVendorConsent

Inherits:
VendorConsent
  • Object
show all
Defined in:
lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb

Instance Method Summary collapse

Methods inherited from VendorConsent

#getAllowedPurposesIds

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

#getAllowedPurposeIdsObject



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

#getAllowedPurposesObject



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

#getAllowedPurposesBitsObject



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

#getCmpIdObject



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

#getCmpVersionObject



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

#getConsentLanguageObject



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

#getConsentRecordCreatedObject



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

#getConsentRecordLastUpdatedObject



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

#getConsentScreenObject



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

#getMaxVendorIdObject



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

#getVendorListVersionObject



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

#getVersionObject



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

#hashCodeObject



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

#toByteArrayObject



95
96
97
# File 'lib/iab_consent_string/consent/implementation/v1/byte_buffer_backed_vendor_consent.rb', line 95

def toByteArray
  @bits.toByteArray()
end

#toStringObject



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