Class: IABConsentString::Consent::Range::StartEndRangeEntry

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

Instance Method Summary collapse

Constructor Details

#initialize(startVendorId, endVendorId) ⇒ StartEndRangeEntry

Returns a new instance of StartEndRangeEntry.



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

def initialize(startVendorId,endVendorId)
  @startVendorId = startVendorId
  @endVendorId = endVendorId
end

Instance Method Details

#appendTo(buffer, currentOffset) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/iab_consent_string/consent/range/start_end_range_entry.rb', line 19

def appendTo(buffer, currentOffset)
  newOffset = currentOffset
  buffer.setBit(newOffset)
  newOffset += 1
  buffer.setInt(newOffset, IABConsentString::GDPRConstants::VENDOR_ID_SIZE, @startVendorId)
  newOffset += IABConsentString::GDPRConstants::VENDOR_ID_SIZE
  buffer.setInt(newOffset, IABConsentString::GDPRConstants::VENDOR_ID_SIZE, @endVendorId)
  newOffset += IABConsentString::GDPRConstants::VENDOR_ID_SIZE
  newOffset
end

#sizeObject



14
15
16
17
# File 'lib/iab_consent_string/consent/range/start_end_range_entry.rb', line 14

def size()
  #  One bit for SingleOrRange flag, 2 * VENDOR_ID_SIZE for 2 vendor IDs
  1 + ( IABConsentString::GDPRConstants::VENDOR_ID_SIZE * 2 )
end

#valid(maxVendorId) ⇒ Object



30
31
32
# File 'lib/iab_consent_string/consent/range/start_end_range_entry.rb', line 30

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