Class: IABConsentString::Consent::Range::SingleRangeEntry

Inherits:
RangeEntry
  • Object
show all
Defined in:
lib/iab_consent_string/consent/range/single_range_entry.rb

Instance Method Summary collapse

Constructor Details

#initialize(singleVendorId) ⇒ SingleRangeEntry

Returns a new instance of SingleRangeEntry.



9
10
11
# File 'lib/iab_consent_string/consent/range/single_range_entry.rb', line 9

def initialize(singleVendorId)
  @singleVendorId = singleVendorId
end

Instance Method Details

#appendTo(buffer, currentOffset) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/iab_consent_string/consent/range/single_range_entry.rb', line 18

def appendTo(buffer, currentOffset)
  newOffset = currentOffset
  buffer.unsetBit(newOffset)
  newOffset += 1
  buffer.setInt(newOffset, IABConsentString::GDPRConstants::VENDOR_ID_SIZE, @singleVendorId)
  newOffset += IABConsentString::GDPRConstants::VENDOR_ID_SIZE
  newOffset
end

#sizeObject



13
14
15
16
# File 'lib/iab_consent_string/consent/range/single_range_entry.rb', line 13

def size()
  #  One bit for SingleOrRange flag, VENDOR_ID_SIZE for single vendor ID
  1 + IABConsentString::GDPRConstants::VENDOR_ID_SIZE
end

#valid(maxVendorId) ⇒ Object



27
28
29
# File 'lib/iab_consent_string/consent/range/single_range_entry.rb', line 27

def valid(maxVendorId)
  (@singleVendorId > 0) && (@singleVendorId <= maxVendorId)
end