Module: Rakie::Proto

Included in:
HttpRequest, HttpResponse, WebsocketBasicMessage
Defined in:
lib/rakie/proto.rb

Constant Summary collapse

PARSE_BEGIN =
0

Instance Method Summary collapse

Instance Method Details

#parse(source) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rakie/proto.rb', line 39

def parse(source)
  status = ParseStatus::CONTINUE
  
  while status == ParseStatus::CONTINUE
    status = self.deserialize(source)
  end

  if status == ParseStatus::PENDING
    status = ParseStatus::CONTINUE
  end

  offset = @parse_offset
  @parse_status = status
  @parse_offset = 0

  return offset
end

#parse_offsetInteger



29
30
31
# File 'lib/rakie/proto.rb', line 29

def parse_offset
  @parse_offset ||= 0
end

#parse_offset=(offset) ⇒ Object



34
35
36
# File 'lib/rakie/proto.rb', line 34

def parse_offset=(offset)
  @parse_offset = offset
end

#parse_stateInteger



18
19
20
# File 'lib/rakie/proto.rb', line 18

def parse_state
  @parse_state ||= PARSE_BEGIN
end

#parse_state=(state) ⇒ Object



23
24
25
26
# File 'lib/rakie/proto.rb', line 23

def parse_state=(state)
  @parse_state = state
  # puts("Set state: #{@parse_state}")
end

#parse_statusInteger



13
14
15
# File 'lib/rakie/proto.rb', line 13

def parse_status
  @parse_status ||= ParseStatus::CONTINUE
end

#to_sString



59
60
61
# File 'lib/rakie/proto.rb', line 59

def to_s
  self.serialize
end