Class: Lightstreamer::EndOfSnapshotMessage

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

Overview

Helper class used by Subscription in order to parse incoming end-of-snapshot messages.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#item_indexFixnum

The index of the item this end-of-snapshot message applies to.

Returns:

  • (Fixnum)


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

def item_index
  @item_index
end

Class Method Details

.parse(line, table_id, items) ⇒ Object

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



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lightstreamer/messages/end_of_snapshot_message.rb', line 14

def parse(line, table_id, items)
  message = new

  match = line.match Regexp.new("^#{table_id},(\\d+),EOS$")
  return unless match

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

  message
end