Model for reading created
State pattern implemented
This commit is contained in:
18
app/helpers/InSyncState.rb
Normal file
18
app/helpers/InSyncState.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class InSyncState < StatePattern::State
|
||||
|
||||
END_OF_FRAME = "!\n"
|
||||
|
||||
def handle_byte_stream(bytes)
|
||||
idx = 0
|
||||
frame = ""
|
||||
while (idx < bytes.length && bytes[idx] != END_OF_FRAME[0]) do
|
||||
frame = frame + bytes[idx]
|
||||
idx = idx +1
|
||||
end
|
||||
p "------ FRAME -----"
|
||||
frame_lines = frame.split("\n")
|
||||
p frame_lines # should call to higher level
|
||||
p "##################"
|
||||
return ""
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user