Class: Protor::UDPFormatter
- Inherits:
-
Object
- Object
- Protor::UDPFormatter
- Defined in:
- lib/protor/udp_formatter.rb
Constant Summary collapse
- LF =
"\n".freeze
Instance Attribute Summary collapse
-
#max_packet_size ⇒ Object
readonly
Returns the value of attribute max_packet_size.
Instance Method Summary collapse
- #format(registry) {|str| ... } ⇒ Object
-
#initialize(max_packet_size) ⇒ UDPFormatter
constructor
A new instance of UDPFormatter.
Constructor Details
#initialize(max_packet_size) ⇒ UDPFormatter
Returns a new instance of UDPFormatter.
7 8 9 |
# File 'lib/protor/udp_formatter.rb', line 7 def initialize(max_packet_size) @max_packet_size = max_packet_size end |
Instance Attribute Details
#max_packet_size ⇒ Object (readonly)
Returns the value of attribute max_packet_size.
3 4 5 |
# File 'lib/protor/udp_formatter.rb', line 3 def max_packet_size @max_packet_size end |
Instance Method Details
#format(registry) {|str| ... } ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/protor/udp_formatter.rb', line 11 def format(registry) return unless block_given? str = "" size = 0 registry.each do |entry| line = stringify(entry) if size + line.size > max_packet_size yield(str) str = line size = line.size else str << line size += line.size end end yield(str) end |