Class: BinaryPList::Parser::ObjectReaders::Int

Inherits:
Base
  • Object
show all
Defined in:
lib/binary_plist/parser/object_readers/int.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BinaryPList::Parser::ObjectReaders::Base

Class Method Details

.reads?(marker) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/binary_plist/parser/object_readers/int.rb', line 9

def self.reads?(marker)
  (0b0001_0000..0b0001_1111).include?(marker)
end

Instance Method Details

#read(marker) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/binary_plist/parser/object_readers/int.rb', line 13

def read(marker)
  raise UnsupportedMarkerError, marker unless self.class.reads?(marker)

  marker_length = marker & 0xF

  bytes_count = (1 << marker_length)
  # raise OffsetOutOfRangeError if outside_object_table?(io.tell + bytes_count)

  read_int(bytes_count)
end