Sha256: 86d5e1c20bd7d262dffb8808ef2a2daa3ae7a4fdab07ccbcc8c6fddc3503aeda
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
class KJess::Response class DumpedStats < KJess::Response keyword 'queue' arity 2 attr_accessor :data # Internal: Read the extra data from the value # # Read the datablock that is after the value and then the final END marker. # # Returns nothing def read_more( connection ) queue_line_re = /\Aqueue\s+'(\S+)' \{\Z/ stat_line_re = /\A(\w+)=(\S+)\Z/ stats = Hash.new line = message.strip current_queue = nil begin line.strip! if md = stat_line_re.match( line ) then stats[current_queue][md.captures[0]] = convert_value( md.captures[1] ) elsif md = queue_line_re.match( line ) then current_queue = md.captures.first stats[current_queue] = Hash.new elsif line == "}" then current_queue = nil elsif line == "END" then break else # do nothing -- empty line end end while line = connection.readline @data = stats end def convert_value( value ) if value =~ /\A\d+\Z/ then Float( value ).to_i elsif value =~ /\A\d+\.\d+\Z/ Float( value ) else value end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
kjess-1.2.0 | lib/kjess/response/dumped_stats.rb |
kjess-1.1.0 | lib/kjess/response/dumped_stats.rb |
kjess-1.0.0 | lib/kjess/response/dumped_stats.rb |