class EventStreamParser::Parser
def process_field(field, value)
def process_field(field, value) ## # The steps to process the field given a field name and a field value depend # on the field name, as given in the following list. Field names must be # compared literally, with no case folding performed. # case field ## # If the field name is "event" # when 'event' ## # Set the event type buffer to field value. # @event_type_buffer = value ## # If the field name is "data" # when 'data' ## # Append the field value to the data buffer, then append a single U+000A # LINE FEED (LF) character to the data buffer. # @data_buffer << value << "\n" ## # If the field name is "id" # when 'id' ## # If the field value does not contain U+0000 NULL, then set the last event # ID buffer to the field value. Otherwise, ignore the field. # @last_event_id_buffer = value unless value.include?("\u0000") ## # If the field name is "retry" # when 'retry' ## # If the field value consists of only ASCII digits, then interpret the # field value as an integer in base ten, and set the event stream's # reconnection time to that integer. Otherwise, ignore the field. # @reconnection_time = value.to_i if /\A\d+\z/.match?(value) ## # Otherwise # else ## # The field is ignored. # ignore end end