Sha256: 9a0eac744a7d40613a2c5b99a8cef10efafffe869de38fb568fd19df81c5ae61

Contents?: true

Size: 921 Bytes

Versions: 1

Compression:

Stored size: 921 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
      if block_given?
        @context = Proc.new
      else
        @context
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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