class Lightstreamer::OverflowMessage

Helper class used by {Subscription} in order to parse incoming overflow messages.

@private

Attributes

item_index[RW]

The index of the item this overflow message applies to.

@return [Fixnum]

overflow_size[RW]

The size of the overflow that occurred.

@return [Fixnum]

Public Class Methods

parse(line, table_id, items) click to toggle source

Attempts to parses the specified line as an overflow message for the given table and items and returns an instance of {OverflowMessage} on success, or `nil` on failure.

# File lib/lightstreamer/messages/overflow_message.rb, line 19
def parse(line, table_id, items)
  match = line.match table_regexp(table_id)
  return unless match

  message = new

  message.item_index = match.captures[0].to_i - 1
  return unless message.item_index < items.size

  message.overflow_size = match.captures[1].to_i

  message
end

Private Class Methods

table_regexp(table_id) click to toggle source
# File lib/lightstreamer/messages/overflow_message.rb, line 35
def table_regexp(table_id)
  Regexp.new "^#{table_id},(\\d+),OV(\\d+)$"
end