class XCActivityLog::Parser::S
Constants
- EPOCH
Public Class Methods
new(tokens, class_deserializer:)
click to toggle source
Calls superclass method
SLF0::Token::Stream::new
# File lib/xcactivitylog/parser.rb, line 9 def initialize(tokens, class_deserializer:) super(tokens, class_deserializer: class_deserializer) @version = int { 'activity log version' } end
Public Instance Methods
boolean(&reason_blk)
click to toggle source
# File lib/xcactivitylog/parser.rb, line 35 def boolean(&reason_blk) int(&reason_blk) != 0 end
deserialize_instance_of(stream, cls)
click to toggle source
# File lib/xcactivitylog/parser.rb, line 24 def deserialize_instance_of(stream, cls) instance = cls.new cls.attributes.each do |attr| next if attr.first_version > @version || attr.first_version_without <= @version value = stream.send(attr.type) { "#{attr.name} for #{cls.name.split('::').last} #{instance.inspect}" } instance.instance_variable_set(:"@#{attr.name}", value) end instance.freeze end
deserializer_for(class_ref_num)
click to toggle source
# File lib/xcactivitylog/parser.rb, line 14 def deserializer_for(class_ref_num) class_name, = @class_deserializer[class_ref_num] cls = XCActivityLog.const_get(class_name) raise "invalid #{class_name} #{cls}" unless cls < SerializedObject lambda do |stream| deserialize_instance_of(stream, cls) end end
document_location(&reason_blk)
click to toggle source
# File lib/xcactivitylog/parser.rb, line 43 def document_location(&reason_blk) return if shift_nil? object(&reason_blk).tap do |o| raise "expected location, got #{o.class.name} for #{reason_blk&.call}" unless o.is_a?(DVTDocumentLocation) end end
nsrange(&_reason_blk)
click to toggle source
# File lib/xcactivitylog/parser.rb, line 39 def nsrange(&_reason_blk) deserialize_instance_of(self, NSRange) end
time(&reason_blk)
click to toggle source
# File lib/xcactivitylog/parser.rb, line 53 def time(&reason_blk) EPOCH.+(double(&reason_blk)).freeze end
unexpected_token!(expected_class, token, &reason_blk)
click to toggle source
# File lib/xcactivitylog/parser.rb, line 57 def unexpected_token!(expected_class, token, &reason_blk) raise "expected #{expected_class} got #{token.inspect} for #{reason_blk&.call} (XCActivityLog version #{@version})" end