Sha256: d34985f416adc769df8ffbeda04518dac26210a0aa044f558769b1b0413610ec

Contents?: true

Size: 759 Bytes

Versions: 5

Compression:

Stored size: 759 Bytes

Contents

require 'json'

module Norikra
  class Stats
    attr_accessor :host, :port, :threads, :log
    attr_accessor :targets, :queries

    def initialize(opts={})
      @host = opts[:host]
      @port = opts[:port]
      @threads = opts[:threads]
      @log = opts[:log]
      @targets = opts[:targets] || []
      @queries = opts[:queries] || []
    end

    def to_hash
      {host: @host, port: @port, threads: @threads, log: @log, targets: @targets, queries: @queries}
    end

    def dump(path)
      File.open(path, 'w') do |file|
        file.write(JSON.pretty_generate(self.to_hash))
      end
    end

    def self.load(path)
      File.open(path, 'r') do |file|
        self.new(JSON.parse(file.read, symbolize_names: true))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
norikra-0.0.16-java lib/norikra/stats.rb
norikra-0.0.15-java lib/norikra/stats.rb
norikra-0.0.14-java lib/norikra/stats.rb
norikra-0.0.13-java lib/norikra/stats.rb
norikra-0.0.12-java lib/norikra/stats.rb