Sha256: 8d2fc2daa3bff7861892506f3c213a3875dcd3030309994b866236c389951121

Contents?: true

Size: 919 Bytes

Versions: 1

Compression:

Stored size: 919 Bytes

Contents

module L2meter
  class Configuration
    attr_writer :context, :output
    attr_accessor :source, :prefix, :float_precision, :scrubber
    attr_reader :key_formatter, :output

    DEFAULT_KEY_FORMATTER = ->(key) do
      key.to_s.strip.downcase.gsub(/[^-a-z\d.#]+/, "-")
    end

    private_constant :DEFAULT_KEY_FORMATTER

    def initialize
      @sort = false
      @key_formatter = DEFAULT_KEY_FORMATTER
      @output = $stdout
      @float_precision = 4
      @context = nil
      @compact_values = true
    end

    def format_keys(&block)
      @key_formatter = block
    end

    def sort?
      @sort
    end

    def sort=(value)
      @sort = !!value
    end

    def compact_values?
      @compact_values
    end

    def compact_values=(value)
      @compact_values = !!value
    end

    def context(&block)
      if block
        @context = block
      else
        @context
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
l2meter-0.15.1 lib/l2meter/configuration.rb