Sha256: 60386cfd23e76d90cb4b5b72ff1fc2a53381a94ac46199a7e746b4ae045ee167

Contents?: true

Size: 365 Bytes

Versions: 6

Compression:

Stored size: 365 Bytes

Contents

# frozen_string_literal: true

module Riemann
  module Tools
    module Utils # :nodoc:
      def reverse_numeric_sort_with_header(data, header: 1, count: 10)
        lines = data.chomp.split("\n")
        header = lines.shift(header)

        lines.sort_by!(&:to_f)
        lines.reverse!

        (header + lines[0, count]).join("\n")
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
riemann-tools-1.4.0 lib/riemann/tools/utils.rb
riemann-tools-1.3.0 lib/riemann/tools/utils.rb
riemann-tools-1.2.0 lib/riemann/tools/utils.rb
riemann-tools-1.1.1 lib/riemann/tools/utils.rb
riemann-tools-1.1.0 lib/riemann/tools/utils.rb
riemann-tools-1.0.0 lib/riemann/tools/utils.rb