Model for reading created
State pattern implemented
This commit is contained in:
13
app/helpers/SearchingForSyncState.rb
Normal file
13
app/helpers/SearchingForSyncState.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class SearchingForSyncState < StatePattern::State
|
||||
def handle_byte_stream(bytes)
|
||||
idx = 0;
|
||||
# spool unwanted bytes
|
||||
while (bytes[idx] != Synchronizer::SYNC_PATTERN[0]) do idx = idx+1 end
|
||||
|
||||
#p "Found pattern at idx = #{idx}"
|
||||
transition_to(ConfirmingSyncPatternState)
|
||||
|
||||
# return
|
||||
return bytes[idx..-1]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user