Class: Lightstreamer::UpdateMessage
- Inherits:
-
Object
- Object
- Lightstreamer::UpdateMessage
- Defined in:
- lib/lightstreamer/messages/update_message.rb
Overview
Helper class used by Subscription in order to parse incoming update messages.
Instance Attribute Summary collapse
-
#data ⇒ Array
The field data specified by this update message.
-
#item_index ⇒ Fixnum
The index of the item this update message applies to.
Class Method Summary collapse
-
.parse(line, table_id, items, fields) ⇒ Object
Attempts to parses the specified line as an update message for the given table, items, and fields, and returns an instance of UpdateMessage on success, or ‘nil` on failure.
Instance Attribute Details
#data ⇒ Array
The field data specified by this update message.
14 15 16 |
# File 'lib/lightstreamer/messages/update_message.rb', line 14 def data @data end |
#item_index ⇒ Fixnum
The index of the item this update message applies to.
9 10 11 |
# File 'lib/lightstreamer/messages/update_message.rb', line 9 def item_index @item_index end |
Class Method Details
.parse(line, table_id, items, fields) ⇒ Object
Attempts to parses the specified line as an update message for the given table, items, and fields, and returns an instance of Lightstreamer::UpdateMessage on success, or ‘nil` on failure.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lightstreamer/messages/update_message.rb', line 19 def parse(line, table_id, items, fields) match = line.match table_regexp(table_id, fields) return unless match = new .item_index = match.captures[0].to_i - 1 return unless .item_index < items.size .data = parse_field_values match.captures[1..-1], fields end |