Class: StreamWrapper::OrderBlobSplitter
- Inherits:
-
Object
- Object
- StreamWrapper::OrderBlobSplitter
- Defined in:
- lib/logbox/stream_wrapper/order_blob_splitter.rb
Overview
Modfies and injects buy_basket blob information into stream.
-
Inserts attributes from buy_basket blob into the buy_basket observation.
-
Adds a buy_item observation for each item in the basket.
Instance Method Summary collapse
- #eof? ⇒ Boolean
- #gets ⇒ Object
-
#initialize(input) ⇒ OrderBlobSplitter
constructor
A new instance of OrderBlobSplitter.
Constructor Details
#initialize(input) ⇒ OrderBlobSplitter
Returns a new instance of OrderBlobSplitter.
9 10 11 12 13 |
# File 'lib/logbox/stream_wrapper/order_blob_splitter.rb', line 9 def initialize (input) input = StringIO.new(input) if input.class == String # Used for testing. @stream = input @buy_item_lines = [] end |
Instance Method Details
#eof? ⇒ Boolean
28 29 30 |
# File 'lib/logbox/stream_wrapper/order_blob_splitter.rb', line 28 def eof? @stream.eof? end |
#gets ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/logbox/stream_wrapper/order_blob_splitter.rb', line 15 def gets if @buy_item_lines.size > 0 return @buy_item_lines.shift end line = @stream.gets if line && line.include?("&o=buy_basket&") extract_buy_items(line) line = reformat_buy_basket(line) end line end |