Sha256: 11ee6a17e0c61656abdee87bf0289d846640a7e5aaf912d506ef807b50a70cf2

Contents?: true

Size: 769 Bytes

Versions: 4

Compression:

Stored size: 769 Bytes

Contents

module L2meter
  class Configuration
    attr_writer :output
    attr_accessor :source, :prefix, :float_precision, :scrubber
    attr_reader :context, :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
    end

    def format_keys(&block)
      @key_formatter = block
    end

    def sort?
      @sort
    end

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

    def context
      if block_given?
        @context = Proc.new
      else
        @context
      end
    end

    attr_writer :context
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
l2meter-0.13.0 lib/l2meter/configuration.rb
l2meter-0.12.0 lib/l2meter/configuration.rb
l2meter-0.11.0 lib/l2meter/configuration.rb
l2meter-0.10.0 lib/l2meter/configuration.rb