Class: PStream::Stream

Inherits:
Object
  • Object
show all
Defined in:
lib/pstream/stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pcap, prot, id, desc, frames) ⇒ Stream

Returns a new instance of Stream.



14
15
16
17
18
19
20
# File 'lib/pstream/stream.rb', line 14

def initialize(pcap, prot, id, desc, frames)
    @desc = desc
    @frames = frames
    @id = id
    @pcap = pcap
    @prot = prot
end

Instance Attribute Details

#descObject

Returns the value of attribute desc.



2
3
4
# File 'lib/pstream/stream.rb', line 2

def desc
  @desc
end

#framesObject

Returns the value of attribute frames.



3
4
5
# File 'lib/pstream/stream.rb', line 3

def frames
  @frames
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/pstream/stream.rb', line 4

def id
  @id
end

Instance Method Details

#contentsObject



6
7
8
9
10
11
12
# File 'lib/pstream/stream.rb', line 6

def contents
    out = %x(
        tshark -r #{@pcap} -z follow,#{@prot},hex,#{@id} | \
             sed "s|^	||" | \grep -E "^[0-9A-Fa-f]{8}"
    )
    return out
end

#to_sObject



22
23
24
# File 'lib/pstream/stream.rb', line 22

def to_s()
    return contents
end