Class: Mu::Xtractr::Stream
- Inherits:
-
Object
- Object
- Mu::Xtractr::Stream
- Includes:
- Enumerable
- Defined in:
- lib/mu/xtractr/stream.rb,
lib/mu/xtractr/stream/http.rb,
lib/mu/xtractr/test/tc_stream.rb,
lib/mu/xtractr/test/stream/tc_http.rb
Overview
end
Defined Under Namespace
Classes: HTTP, Message, Processor, Test
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Return a list of extracted content from the messages.
-
#flow ⇒ Object
readonly
Return the flow that this stream represents.
-
#messages ⇒ Object
readonly
Return a list of Messages in this stream.
-
#xtractr ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#each_message(&blk) ⇒ Object
(also: #each)
Iterate over each message in this stream.
-
#initialize(xtractr, flow, json) ⇒ Stream
constructor
:nodoc:.
-
#inspect ⇒ Object
:nodoc:.
Constructor Details
#initialize(xtractr, flow, json) ⇒ Stream
:nodoc:
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/mu/xtractr/stream.rb', line 93 def initialize xtractr, flow, json # :nodoc: @xtractr = xtractr @flow = flow @messages = [] @contents = [] json['packets'].each do |pkt| bytes = (pkt['b'] || []).map { |b| b.chr }.join('') if .empty? or [-1].dir != pkt['d'] << Message.new(self, .size, pkt['d'], '') end [-1].bytes << bytes end # Run the stream/messages through each registered processor to pull # out attachments, files, etc Processor.processors.each do |processor| if processor.matches? self processor.extract self break end end end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Return a list of extracted content from the messages.
59 60 61 |
# File 'lib/mu/xtractr/stream.rb', line 59 def contents @contents end |
#flow ⇒ Object (readonly)
Return the flow that this stream represents.
53 54 55 |
# File 'lib/mu/xtractr/stream.rb', line 53 def flow @flow end |
#messages ⇒ Object (readonly)
Return a list of Messages in this stream.
56 57 58 |
# File 'lib/mu/xtractr/stream.rb', line 56 def @messages end |
#xtractr ⇒ Object (readonly)
:nodoc:
50 51 52 |
# File 'lib/mu/xtractr/stream.rb', line 50 def xtractr @xtractr end |
Instance Method Details
#each_message(&blk) ⇒ Object Also known as: each
Iterate over each message in this stream
118 119 120 121 |
# File 'lib/mu/xtractr/stream.rb', line 118 def &blk .each(&blk) return self end |
#inspect ⇒ Object
:nodoc:
123 124 125 |
# File 'lib/mu/xtractr/stream.rb', line 123 def inspect # :nodoc: return "#<stream:#{flow.id} ##{.size} messages>" end |