Class: DIY::Packet

Inherits:
Object
  • Object
show all
Defined in:
lib/diy/packet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, detail_msg = nil) ⇒ Packet

Returns a new instance of Packet.



3
4
5
6
# File 'lib/diy/packet.rb', line 3

def initialize( content, detail_msg = nil )
  @content = content
  @detail_msg = detail_msg
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



7
8
9
# File 'lib/diy/packet.rb', line 7

def content
  @content
end

#detail_msgObject (readonly)

Returns the value of attribute detail_msg.



7
8
9
# File 'lib/diy/packet.rb', line 7

def detail_msg
  @detail_msg
end

Instance Method Details

#inspectObject



14
15
16
# File 'lib/diy/packet.rb', line 14

def inspect
  "#<#{self.class.name}: #{Utils.pp(@content)}, from #{@detail_msg}>"
end

#pretty_print(lsize = 150) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/diy/packet.rb', line 18

def pretty_print(lsize = 150)
  real = Utils.pp(@content, false)
  dot = nil
  if inspect.size >= lsize
    dot = "..."
  end
  sprintf "%-#{lsize+2}.#{lsize}s%3s (size= %4d), from %20s", real,dot,@content.size,@detail_msg
end

#to_sObject



10
11
12
# File 'lib/diy/packet.rb', line 10

def to_s
  @content
end