Class: BinaryPList::Parser::ObjectReaders::ASCIIString
- Inherits:
-
Base
- Object
- Base
- BinaryPList::Parser::ObjectReaders::ASCIIString
show all
- Defined in:
- lib/binary_plist/parser/object_readers/ascii_string.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Class Method Details
.reads?(marker) ⇒ Boolean
10
11
12
|
# File 'lib/binary_plist/parser/object_readers/ascii_string.rb', line 10
def self.reads?(marker)
(0b0101_0000..0b0101_1111).include?(marker)
end
|
Instance Method Details
#read(marker) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/binary_plist/parser/object_readers/ascii_string.rb', line 14
def read(marker)
raise UnsupportedMarkerError, marker unless self.class.reads?(marker)
@marker = marker
read_bytes(string_length)
.force_encoding("ASCII-8BIT")
.encode("UTF-8")
end
|
#string_length ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/binary_plist/parser/object_readers/ascii_string.rb', line 24
def string_length
@string_length ||= if (@marker & 0xF) == 0xF
Int.new(nil, io, offset_table, trailer)
.read(read_byte)
else
@marker & 0xF
end
end
|