Class: DIY::Packet
- Inherits:
-
Object
- Object
- DIY::Packet
- Defined in:
- lib/diy/packet.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#detail_msg ⇒ Object
readonly
Returns the value of attribute detail_msg.
Instance Method Summary collapse
-
#initialize(content, detail_msg = nil) ⇒ Packet
constructor
A new instance of Packet.
- #inspect ⇒ Object
- #pretty_print(lsize = 150) ⇒ Object
- #to_s ⇒ Object
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
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/diy/packet.rb', line 7 def content @content end |
#detail_msg ⇒ Object (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
#inspect ⇒ Object
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_s ⇒ Object
10 11 12 |
# File 'lib/diy/packet.rb', line 10 def to_s @content end |