Class: Lightstreamer::OverflowMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/lightstreamer/messages/overflow_message.rb

Overview

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#item_indexFixnum

The index of the item this overflow message applies to.

Returns:

  • (Fixnum)


9
10
11
# File 'lib/lightstreamer/messages/overflow_message.rb', line 9

def item_index
  @item_index
end

#overflow_sizeFixnum

The size of the overflow that occurred.

Returns:

  • (Fixnum)


14
15
16
# File 'lib/lightstreamer/messages/overflow_message.rb', line 14

def overflow_size
  @overflow_size
end

Class Method Details

.parse(line, table_id, items) ⇒ Object

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



19
20
21
22
23
24
25
26
27
28
29
30
31
# 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